Toggle Toolbar Captions Using Tag

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 iEnd SubPrivate Sub mnuToolbarImageText_Click()	mnuToolbarImageText.Checked = Not _		mnuToolbarImageText.Checked	HideShowToolbarText (mnuToolbarImageText.Checked)End Sub


Share the Post: