Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Fügt eine vorhandene Symbolleisten-Schaltfläche an der angegebenen Position in die Auflistung der Symbolleisten-Schaltflächen ein.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Sub Insert ( _
index As Integer, _
button As ToolBarButton _
)
'Usage
Dim instance As ToolBarButtonCollection
Dim index As Integer
Dim button As ToolBarButton
instance.Insert(index, button)
public void Insert (
int index,
ToolBarButton button
)
public:
void Insert (
int index,
ToolBarButton^ button
)
public void Insert (
int index,
ToolBarButton button
)
public function Insert (
index : int,
button : ToolBarButton
)
Parameter
- index
Die indizierte Position in der Auflistung, an der die Symbolleisten-Schaltfläche eingefügt werden soll.
- button
Der einzufügende ToolBarButton.
Hinweise
Sie können der Auflistung auch mithilfe der Add-Methode oder der AddRange-Methode neue ToolBarButton-Objekte hinzufügen.
Einen zuvor hinzugefügten ToolBarButton können Sie mit der Remove-Methode, der RemoveAt-Methode oder der Clear-Methode entfernen.
Beispiel
Im folgenden Codebeispiel wird ein vorhandener ToolBarButton aus einem ToolBar-Steuerelement entfernt, sofern vorhanden. Außerdem werden in die ToolBar vier neue ToolBarButton-Objekte eingefügt. Für dieses Beispiel ist es erforderlich, dass ein Form mit einem ToolBar-Steuerelement vorhanden ist.
Private Sub AddToolbarButtons(toolBar As ToolBar)
If Not toolBar.Buttons.IsReadOnly Then
' If toolBarButton1 in in the collection, remove it.
If toolBar.Buttons.Contains(toolBarButton1) Then
toolBar.Buttons.Remove(toolBarButton1)
End If
' Create three toolbar buttons.
Dim tbb1 As New ToolBarButton("tbb1")
Dim tbb2 As New ToolBarButton("tbb2")
Dim tbb3 As New ToolBarButton("tbb3")
' Add toolbar buttons to the toolbar.
toolBar.Buttons.AddRange(New ToolBarButton() {tbb2, tbb3})
toolBar.Buttons.Add("tbb4")
' Insert tbb1 into the first position in the collection.
toolBar.Buttons.Insert(0, tbb1)
End If
End Sub
private void AddToolbarButtons(ToolBar toolBar)
{
if(!toolBar.Buttons.IsReadOnly)
{
// If toolBarButton1 in in the collection, remove it.
if(toolBar.Buttons.Contains(toolBarButton1))
{
toolBar.Buttons.Remove(toolBarButton1);
}
// Create three toolbar buttons.
ToolBarButton tbb1 = new ToolBarButton("tbb1");
ToolBarButton tbb2 = new ToolBarButton("tbb2");
ToolBarButton tbb3 = new ToolBarButton("tbb3");
// Add toolbar buttons to the toolbar.
toolBar.Buttons.AddRange(new ToolBarButton[] {tbb2, tbb3});
toolBar.Buttons.Add("tbb4");
// Insert tbb1 into the first position in the collection.
toolBar.Buttons.Insert(0, tbb1);
}
}
void AddToolbarButtons( ToolBar^ toolBar )
{
if ( !toolBar->Buttons->IsReadOnly )
{
// If toolBarButton1 in in the collection, remove it.
if ( toolBar->Buttons->Contains( toolBarButton1 ) )
{
toolBar->Buttons->Remove( toolBarButton1 );
}
// Create three toolbar buttons.
ToolBarButton^ tbb1 = gcnew ToolBarButton( "tbb1" );
ToolBarButton^ tbb2 = gcnew ToolBarButton( "tbb2" );
ToolBarButton^ tbb3 = gcnew ToolBarButton( "tbb3" );
// Add toolbar buttons to the toolbar.
array<ToolBarButton^>^buttons = {tbb2,tbb3};
toolBar->Buttons->AddRange( buttons );
toolBar->Buttons->Add( "tbb4" );
// Insert tbb1 into the first position in the collection.
toolBar->Buttons->Insert( 0, tbb1 );
}
}
private void AddToolbarButtons(ToolBar toolBar)
{
if (!(toolBar.get_Buttons().get_IsReadOnly())) {
// If toolBarButton1 in in the collection, remove it.
if (toolBar.get_Buttons().Contains(toolBarButton1)) {
toolBar.get_Buttons().Remove(toolBarButton1);
}
// Create three toolbar buttons.
ToolBarButton tbb1 = new ToolBarButton("tbb1");
ToolBarButton tbb2 = new ToolBarButton("tbb2");
ToolBarButton tbb3 = new ToolBarButton("tbb3");
// Add toolbar buttons to the toolbar.
toolBar.get_Buttons().AddRange(new ToolBarButton[] { tbb2, tbb3 });
toolBar.get_Buttons().Add("tbb4");
// Insert tbb1 into the first position in the collection.
toolBar.get_Buttons().Insert(0, tbb1);
}
} //AddToolbarButtons
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
ToolBar.ToolBarButtonCollection-Klasse
ToolBar.ToolBarButtonCollection-Member
System.Windows.Forms-Namespace
Add
AddRange