Microsoft KB Archive/327154

= BUG: Toolbar Buttons Show No Text or Images If ButtonSize and Font Properties Set After Buttons Added To Toolbar =

Article ID: 327154

Article Last Modified on 8/28/2005

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition
 * Microsoft Visual Studio .NET 2003 Academic Edition

-



This article was previously published under Q327154



SYMPTOMS
When you customize the buttons in a toolbar by changing the ButtonSize and Font properties of the toolbar control in the IDE, the text and images do not appear on the toolbar buttons at run time, although they appear correct at design time.



CAUSE
When you set the ButtonSize and Font properties after the ToolBar.Buttons.AddRange method is called, those properties do not take effect, and text and images do not appear on the buttons.



RESOLUTION
To work around this problem, follow these steps:  Expand the &quot;Windows Form Designer generated code&quot; section in the code view of the form.  Expand the private void InitializeComponent method and look for a statement similar to the following: ToolBar.Buttons.AddRange(...);  Paste that statement of code at the end, after all of the properties of that ToolBar control have been set. Build and run the application.

Note Because the IDE generates the code that causes the problem, any changes that you make in the IDE, such as adding new controls or events, cause the IDE to regenerate the code, so the statement that causes the problem returns to its original location. Therefore, every time that you build and test the application, check the code file to make sure that ToolBar.Buttons.AddRange(...); has been moved to the end.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior

 * 1) In Visual Studio .NET, create a Microsoft Visual C# .NET Windows Application project.
 * 2) Drag a ToolBar control on the form.
 * 3) At the top of the Properties window, select the ToolBar control from the drop-down list.
 * 4) Select the Buttons property, and then click the ellipsis (...) button to open the ToolBarButton Collection Editor.
 * 5) Click Add to add a few buttons and add text for these buttons. Click OK to close the editor.
 * 6) In the Properties window of the ToolBar control, change the ButtonSize property to another size, and then change the Font property.
 * 7) Run the application. Notice that the buttons are blank.

Additional query words: toolbar buttonsize font blank

Keywords: kbbug kbnofix kbtoolbar kbctrl kbvs2002sp1sweep KB327154

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.