Assembly: System.Windows.Forms (in system.windows.forms.dll)
Public Sub Toggle
Dim instance As TreeNode instance.Toggle
public void Toggle ()
public: void Toggle ()
public void Toggle ()
public function Toggle ()
Lo stato del nodo della struttura viene modificato da espanso a compresso e viceversa.
Nell'esempio di codice riportato di seguito viene rimosso un oggetto TreeNode quando l'utente fa clic su di esso con il pulsante destro del mouse e ne viene modificato lo stato da espanso a compresso quando l'utente fa clic su di esso con la rotellina del mouse. Nell'esempio si presuppone che sia disponibile un oggetto Form con un controllo TreeView. Nel controllo TreeView dovranno essere presenti due o più nodi principali, ognuno con almeno un nodo figlio.
Private Sub treeView1_MouseDown(sender As Object, _ e As MouseEventArgs) Handles treeView1.MouseDown Select Case e.Button ' Remove the TreeNode under the mouse cursor ' if the right mouse button was clicked. Case MouseButtons.Right treeView1.GetNodeAt(e.X, e.Y).Remove() ' Remove the TreeNode under the mouse cursor ' if the middle mouse button (mouse wheel) was clicked. Case MouseButtons.Middle treeView1.GetNodeAt(e.X, e.Y).Toggle() End Select End Sub
private void treeView1_MouseDown(object sender, MouseEventArgs e) { switch(e.Button) { // Remove the TreeNode under the mouse cursor // if the right mouse button was clicked. case MouseButtons.Right: treeView1.GetNodeAt(e.X, e.Y).Remove(); break; // Remove the TreeNode under the mouse cursor // if the middle mouse button (mouse wheel) was clicked. case MouseButtons.Middle: treeView1.GetNodeAt(e.X, e.Y).Toggle(); break; } }
private: void treeView1_MouseDown( Object^ /*sender*/, MouseEventArgs^ e ) { switch ( e->Button ) { case ::MouseButtons::Right: treeView1->GetNodeAt( e->X, e->Y )->Remove(); break; // Remove the TreeNode under the mouse cursor // if the middle mouse button (mouse wheel) was clicked. case ::MouseButtons::Middle: treeView1->GetNodeAt( e->X, e->Y )->Toggle(); break; } }
private void treeView1_MouseDown(Object sender, MouseEventArgs e)
{
switch (e.get_Button()) {
// Remove the TreeNode under the mouse cursor
// if the right mouse button was clicked.
case MouseButtons.Right:
treeView1.GetNodeAt(e.get_X(), e.get_Y()).Remove();
treeView1.GetNodeAt(e.get_X(), e.get_Y()).Remove();
break;
// Remove the TreeNode under the mouse cursor
// if the middle mouse button (mouse wheel) was clicked.
case get_MouseButtons().Middle:
treeView1.GetNodeAt(e.get_X(), e.get_Y()).Toggle();
break;
}
} //treeView1_MouseDown
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.
Nota