StrataFrame Forum

How to update a ToolStrip after programmatically adding a ToolStripButton

http://forum.strataframe.net/Topic4816.aspx

By Greg McGuffey - 11/28/2006

In the constructor of a form, after the InitializeComponent, I add a ToolStripButton to a ToolStrip. When the form opens the new buttons isn't shown, until I manually move it. I've tried .Update, .Refresh, .Invalidate + .Refresh. I've tried these in the constructor, in form load, in form activate. Nada. How do you get a ToolStrip to repaint after changing the Items collection?
By StrataFrame Team - 11/28/2006

You know... I'm not sure.  Calling Invalidate() will always cause the control to redraw itself.  However, in my test, it worked fine... the button was visible as soon as the form displayed.

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.ThemedToolStrip1.Items.Add(New ToolStripMenuItem("Howdy"))

End Sub

By Greg McGuffey - 11/28/2006

huh. Well, what I finally got to work was to move it slightly, the call refresh...



' Move it bit to left, then back to original place, then it redraws

me.myToolStrip.Location = New System.Drawing.Point(me.myToolStrip.Location.X +1,me.myToolStrip.Location.Y)

me.myToolStrip.Location = New System.Drawing.Point(me.myToolStrip.Location.X -1,me.myToolStrip.Location.Y)

me.myToolStrip.Refresh()
By Trent L. Taylor - 11/28/2006

Good to hear Smile