ToolBar::TextAlign Property

 

Gets or sets the alignment of text in relation to each image displayed on the toolbar button controls.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
property ToolBarTextAlign TextAlign {
	ToolBarTextAlign get();
	void set(ToolBarTextAlign value);
}

Property Value

Type: System.Windows.Forms::ToolBarTextAlign

One of the ToolBarTextAlign values. The default is ToolBarTextAlign.Underneath.

Exception Condition
InvalidEnumArgumentException

The assigned value is not one of the ToolBarTextAlign values.

The Text can be aligned underneath or to the right of the image displayed on the ToolBarButton controls.

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 );
}

.NET Framework
Available since 1.1
Return to top
Show: