Articles in this section
Category / Section

How to get the width of BarItems in WinForms XPToolBar?

1 min read

Width of BarItems

In WinForms Toolbar, BarItem type of controls are used as its Child controls and its size will be calculated based on the defined font. The following code demonstrates the same.

C#

//code used to measure the font width of XPToolBar 
MessageBox.Show("Width Of BarItem2 is " +TextRenderer.MeasureText(this.barItem2.Text + "  ", this.xpToolBar1.Font).Width.ToString());

VB

‘code used to measure the font width of XPToolBar 
MessageBox.Show("Width Of BarItem2 is " & TextRenderer.MeasureText(Me.barItem2.Text & "  ", Me.xpToolBar1.Font).Width.ToString())

Screenshot

Show the width of the Baritem in XPToolBar

Samples:

C#:  XPToolBarExample

VB:  XPToolBarExample

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied