Toolbars Help

  • Thread starter Thread starter zoneal
  • Start date Start date
Z

zoneal

I was wondering

I have a toolbar on a form with two buttons on the toolbar. And also a
timer control, i was wondering if anyone would know the code to make
the two buttons exchange places every 1 second.

Thanks
 
I was wondering

I have a toolbar on a form with two buttons on the toolbar. And also a
timer control, i was wondering if anyone would know the code to make
the two buttons exchange places every 1 second.

A strange request... what possible use could this have other
than pure novelty?

The solution is reasonably simple. The following example
assumes the first two buttons have the Text properties New
and Open and have the ImageIndex properties 0 and 1,
respectively.

The Toolbar's Click even should simply check the sender's
Text property to determine its current "state". If your buttons
have no Text, use the Tag property instead. However, if they're
swapping around every second, they're probably not the most
useful of controls to have in your interface.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim pButton As ToolBarButton
For Each pButton In Toolbar1.Buttons
If pButton.Text = "New" Then
pButton.Text = "Open"
pButton.ImageIndex = 0
ElseIf pButton.Text = "Open" Then
pButton.Text = "New"
pButton.ImageIndex = 1
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top