ToolBar.ToolBarButtonCollection Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Encapsulates a collection of ToolBarButton controls for use by the ToolBar class.
public: ref class ToolBar::ToolBarButtonCollection : System::Collections::IList
public class ToolBar.ToolBarButtonCollection : System.Collections.IList
type ToolBar.ToolBarButtonCollection = class
interface IList
interface ICollection
interface IEnumerable
Public Class ToolBar.ToolBarButtonCollection
Implements IList
- Inheritance
-
ToolBar.ToolBarButtonCollection
- Implements
The following code example creates and initializes a ToolBar and three ToolBarButton controls. The toolbar buttons are assigned to the toolbar and the toolbar is added to the form. This code requires that a Form has already been created.
public:
void InitializeMyToolBar()
{
// Create and initialize the ToolBarButton controls and ToolBar.
ToolBar^ toolBar1 = gcnew ToolBar;
ToolBarButton^ toolBarButton1 = gcnew ToolBarButton;
ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
// Set the Text properties of the ToolBarButton controls.
toolBarButton1->Text = "Open";
toolBarButton2->Text = "Save";
toolBarButton3->Text = "Print";
// Add the ToolBarButton controls to the ToolBar.
toolBar1->Buttons->Add( toolBarButton1 );
toolBar1->Buttons->Add( toolBarButton2 );
toolBar1->Buttons->Add( toolBarButton3 );
// Add the ToolBar to the Form.
Controls->Add( toolBar1 );
}
public void InitializeMyToolBar()
{
// Create and initialize the ToolBarButton controls and ToolBar.
ToolBar toolBar1 = new ToolBar();
ToolBarButton toolBarButton1 = new ToolBarButton();
ToolBarButton toolBarButton2 = new ToolBarButton();
ToolBarButton toolBarButton3 = new ToolBarButton();
// Set the Text properties of the ToolBarButton controls.
toolBarButton1.Text = "Open";
toolBarButton2.Text = "Save";
toolBarButton3.Text = "Print";
// Add the ToolBarButton controls to the ToolBar.
toolBar1.Buttons.Add(toolBarButton1);
toolBar1.Buttons.Add(toolBarButton2);
toolBar1.Buttons.Add(toolBarButton3);
// Add the ToolBar to the Form.
Controls.Add(toolBar1);
}
Public Sub InitializeMyToolBar()
' Create and initialize the ToolBarButton controls and ToolBar.
Dim toolBar1 As New ToolBar()
Dim toolBarButton1 As New ToolBarButton()
Dim toolBarButton2 As New ToolBarButton()
Dim toolBarButton3 As New ToolBarButton()
' Set the Text properties of the ToolBarButton controls.
toolBarButton1.Text = "Open"
toolBarButton2.Text = "Save"
toolBarButton3.Text = "Print"
' Add the ToolBarButton controls to the ToolBar.
toolBar1.Buttons.Add(toolBarButton1)
toolBar1.Buttons.Add(toolBarButton2)
toolBar1.Buttons.Add(toolBarButton3)
' Add the ToolBar to the Form.
Controls.Add(toolBar1)
End Sub
The ToolBar.ToolBarButtonCollection is a zero-based indexed collection used by the ToolBar class to hold all the ToolBarButton controls assigned to the toolbar. Use the Add method to add individual buttons and the Remove method to delete them. Call the Clear method to remove all the buttons from the collection.
Tool |
Initializes a new instance of the ToolBar.ToolBarButtonCollection class and assigns it to the specified toolbar. |
Count |
Gets the number of buttons in the toolbar button collection. |
Is |
Gets a value indicating whether the collection is read-only. |
Item[Int32] |
Gets or sets the toolbar button at the specified indexed location in the toolbar button collection. |
Item[String] |
Gets a ToolBarButton with the specified key from the collection. |
Add(String) |
Adds a new toolbar button to the end of the toolbar button collection with the specified Text property value. |
Add(Tool |
Adds the specified toolbar button to the end of the toolbar button collection. |
Add |
Adds a collection of toolbar buttons to this toolbar button collection. |
Clear() |
Removes all buttons from the toolbar button collection. |
Contains(Tool |
Determines if the specified toolbar button is a member of the collection. |
Contains |
Determines if a ToolBarButton with the specified key is contained in the collection. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Returns an enumerator that can be used to iterate through the toolbar button collection. |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Index |
Retrieves the index of the specified toolbar button in the collection. |
Index |
Retrieves the index of the first occurrence of a ToolBarButton with the specified key. |
Insert(Int32, Tool |
Inserts an existing toolbar button in the toolbar button collection at the specified location. |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Remove(Tool |
Removes a given button from the toolbar button collection. |
Remove |
Removes a given button from the toolbar button collection. |
Remove |
Removes the ToolBarButton with the specified key from the collection. |
To |
Returns a string that represents the current object. (Inherited from Object) |
ICollection. |
Copies the elements of the ICollection to an Array, starting at a particular Array index. |
ICollection. |
Gets a value indicating whether access to the collection is synchronized (thread safe). |
ICollection. |
Gets an object that can be used to synchronize access to the collection of buttons. |
IList. |
Adds the specified toolbar button to the end of the toolbar button collection. |
IList. |
Determines whether the collection contains a specific value. |
IList. |
Determines the index of a specific item in the collection. |
IList. |
Inserts an existing toolbar button in the toolbar button collection at the specified location. |
IList. |
Gets a value indicating whether the collection has a fixed size. |
IList. |
Gets or sets the item at a specified index. |
IList. |
Removes the first occurrence of an item from the collection. |
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
Of |
Filters the elements of an IEnumerable based on a specified type. |
As |
Enables parallelization of a query. |
As |
Converts an IEnumerable to an IQueryable. |
Product | Versions |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: