Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 26, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Toggle Toolbar Captions Using Tag

Many applications have an option to show the toolbars as text and image or text-only. I have seen programmers handle this with two toolbars and show them based on the user's selection. This code uses only one toolbar. The only requirement is to store the desired Caption in each button's Tag property. This technique works only if you are not changing the toolbar button's Tag at run time:
' tbmain is the only toolbar. At design time, the 
' caption of buttons are left blank.
Sub HideShowToolbarText(bShowText As Boolean)
	Dim i As Integer

	For i = 1 To tbMain.Buttons.Count
		tbMain.Buttons(i).Caption = IIf( _
			bShowText, tbMain.Buttons(i).Tag, "")
	Next i
End Sub

Private Sub mnuToolbarImageText_Click()
	mnuToolbarImageText.Checked = Not _
	HideShowToolbarText (mnuToolbarImageText.Checked)
End Sub
Kanthi Chonachalarn
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date