ToolBar::AutoSize Property
Gets or sets a value indicating whether the toolbar adjusts its size automatically, based on the size of the buttons and the dock style.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: [BrowsableAttribute(true)] property bool AutoSize { virtual bool get() override; virtual void set(bool value) override; }
Property Value
Type: System::Booleantrue if the toolbar adjusts its size automatically, based on the size of the buttons and dock style; otherwise, false. The default is true.
When AutoSize is set to true, the ToolBar control sizes itself to accommodate the toolbar buttons, based upon the button size, the number of ToolBarButton objects it contains, and the DockStyle of the toolbar.
The following code example creates a ToolBar control, sets some of its common properties, and adds it to a Form. Delegates are also added to the ButtonClick and ButtonDropDown events. This example requires that a ToolBar named toolBar1 and an ImageList named imageList1 have been declared.
void AddToolBar() { // Add a toolbar and set some of its properties. toolBar1 = gcnew ToolBar; toolBar1->Appearance = System::Windows::Forms::ToolBarAppearance::Flat; toolBar1->BorderStyle = System::Windows::Forms::BorderStyle::None; toolBar1->Buttons->Add( this->toolBarButton1 ); toolBar1->ButtonSize = System::Drawing::Size( 24, 24 ); toolBar1->Divider = true; toolBar1->DropDownArrows = true; toolBar1->ImageList = this->imageList1; toolBar1->ShowToolTips = true; toolBar1->Size = System::Drawing::Size( 292, 25 ); toolBar1->TabIndex = 0; toolBar1->TextAlign = System::Windows::Forms::ToolBarTextAlign::Right; toolBar1->Wrappable = false; // Add handlers for the ButtonClick and ButtonDropDown events. toolBar1->ButtonDropDown += gcnew ToolBarButtonClickEventHandler( this, &MyToolBar::toolBar1_ButtonDropDown ); toolBar1->ButtonClick += gcnew ToolBarButtonClickEventHandler( this, &MyToolBar::toolBar1_ButtonClicked ); // Add the toolbar to the form. this->Controls->Add( toolBar1 ); }
Available since 1.1