Impossibile ottenere «SplitContainer» funzionante (non ricordo i dettagli, ma ho avuto problemi), così oggi sono andato dritto con questa funzione per farlo manualmente. Per comprimere il controllo passare un argomento negativo come «the_sz».
/// <summary>
/// (In|De)creases a height of the «control» and the window «form», and moves accordingly
/// down or up elements in the «move_list». To decrease size pass a negative argument
/// to «the_sz».
/// Usually used to collapse (or expand) elements of a form, and to move controls of the
/// «move_list» down to fill the appeared gap.
/// </summary>
/// <param name="control">control to collapse/expand</param>
/// <param name="form">form to get resized accordingly after the size of a control
/// changed (pass «null» if you don't want to)</param>
/// <param name="move_list">A list of controls that should also be moved up or down to
/// «the_sz» size (e.g. to fill a gap after the «control» collapsed)</param>
/// <param name="the_sz">size to change the control, form, and the «move_list»</param>
public static void ToggleControlY(Control control, Form form, List<Control> move_list, int the_sz)
{
//→ Change sz of ctrl
control.Height += the_sz;
//→ Change sz of Wind
if (form != null)
form.Height += the_sz;
//*** We leaved a gap(or intersected with another controls) now!
//→ So, move up/down a list of a controls
foreach (Control ctrl in move_list)
{
Point loc = ctrl.Location;
loc.Y += the_sz;
ctrl.Location = loc;
}
}
Ho appena inserito un'etichetta su groupBox e ho aggiunto questa funzione all'evento «onClick» dell'etichetta. E per rendere più chiara l'abilità di espansione per gli utenti, ho aggiunto all'inizio del testo il carattere ⇘
.
fonte
2014-11-21 11:05:51
Ho trovato questo fantastico pannello Rich: http://jfblier.wordpress.com/2008/12/10/rich-panel-with-expander/ – aleroot