devxlogo

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

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.