Results 1 to 7 of 7

Thread: Toolbar buttons like Radiobuttons *[RESOLVED]*

  1. #1

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435

    Thumbs up Toolbar buttons like Radiobuttons *[RESOLVED]*

    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:

    VB Code:
    1. Case "Details" 'First button
    2.     pnlDetails.BringToFront()
    3.     [b]OldIndex = 0[/b]
    4.     MessageBox.Show(OldIndex)
    5.     '
    6. Case "Game" 'Second button
    7.     <[i]toolbar1.Buttons.IndexOf(oldindex) = <pop this button out>[/i]>
    8.     ...
    But what exactly is the right code? Can anyone help? Please.
    Last edited by RealNickyDude; Dec 9th, 2002 at 07:27 PM.
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  2. #2
    Member HumanCompiler's Avatar
    Join Date
    Dec 2002
    Location
    Decatur, IN USA
    Posts
    52
    I've never done it before, but I'm guessing it would be something like this...(in the ButtonClick event of the ToolBar)

    Code:
    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?
    -Erik Porter
    .NET MVP

  3. #3

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    I'll try that, thanks.

    (open square bracket)vbcode(close square bracket) blah, blah (open square bracket slash)vbcode(close square bracket)
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  4. #4
    Member HumanCompiler's Avatar
    Join Date
    Dec 2002
    Location
    Decatur, IN USA
    Posts
    52
    right on, thanx

    VB Code:
    1. MessageBox.Show(IIF(Me.NotSoBright, ":(", ":)"))
    -Erik Porter
    .NET MVP

  5. #5

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435

    Question

    I can't get it quite right, this is what I have:

    VB Code:
    1. If ToolBar1.Buttons.IndexOf(e.Button) <> LastButtonIndex Then
    2.                     ToolBar1.Buttons.Item(LastButtonIndex).Pushed = False
    3.                     LastButtonIndex = ToolBar1.Buttons.IndexOf(e.Button)
    4.                 Else
    5.                     [b]ToolBar1.Buttons.Item(ToolBar1.Buttons.IndexOf).Pushed = True[/b]
    6.                 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?
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  6. #6
    Member HumanCompiler's Avatar
    Join Date
    Dec 2002
    Location
    Decatur, IN USA
    Posts
    52
    that line won't really do anything...try this instead...i think you're trying to make it more complicated than it should be

    VB Code:
    1. 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.
    -Erik Porter
    .NET MVP

  7. #7

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    right on, thanx

    VB Code:
    1. MessageBox.Show(IIF(Me.NotSoBright, ":(", ":)"))
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width