PDA

Click to See Complete Forum and Search --> : Toolbar buttons like Radiobuttons *[RESOLVED]*


RealNickyDude
Dec 9th, 2002, 05:25 PM
I have a toolbar with which I want the image that the user clicked upon to stay pressed until another one is pressed, then I wish the last button pressed to pop out and the new button to press in <phew!>

I know I can set the buttonstyles to pushbutton and I know I have to get the index of the last button pressed and I know you have to use something like:


Case "Details" 'First button
pnlDetails.BringToFront()
OldIndex = 0
MessageBox.Show(OldIndex)
'
Case "Game" 'Second button
<toolbar1.Buttons.IndexOf(oldindex) = <pop this button out>>
...
But what exactly is the right code? Can anyone help? Please. :(

HumanCompiler
Dec 9th, 2002, 05:42 PM
I've never done it before, but I'm guessing it would be something like this...(in the ButtonClick event of the ToolBar)



MyToolBar.Buttons.Item(LastButtonIndex).Pushed = False

LastButtonIndex = MyToolBar.Buttons.IndexOf(e.Button)



Hope that helps

btw, what's the tag for formatting your code to VB? :confused:

RealNickyDude
Dec 9th, 2002, 05:48 PM
I'll try that, thanks.

(open square bracket)vbcode(close square bracket) blah, blah (open square bracket slash)vbcode(close square bracket)

HumanCompiler
Dec 9th, 2002, 05:57 PM
right on, thanx :)



MessageBox.Show(IIF(Me.NotSoBright, ":(", ":)"))

RealNickyDude
Dec 9th, 2002, 06:12 PM
I can't get it quite right, this is what I have:

If ToolBar1.Buttons.IndexOf(e.Button) <> LastButtonIndex Then
ToolBar1.Buttons.Item(LastButtonIndex).Pushed = False
LastButtonIndex = ToolBar1.Buttons.IndexOf(e.Button)
Else
ToolBar1.Buttons.Item(ToolBar1.Buttons.IndexOf).Pushed = True
End If
I need the button to stay in still if the user clicks on a pushed in button. The line in bold is giving me trouble, can you help?

HumanCompiler
Dec 9th, 2002, 06:17 PM
that line won't really do anything...try this instead...i think you're trying to make it more complicated than it should be ;)



e.Button.Pushed = True



You just want the button your on to stay pushed right? e.Button is just a reference to the button that was just clicked on.

RealNickyDude
Dec 9th, 2002, 06:26 PM
right on, thanx :)



MessageBox.Show(IIF(Me.NotSoBright, ":(", ":)"))

:D