Results 1 to 5 of 5

Thread: how to change images on toolbar @ runtime???

  1. #1

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510

    Question

    I have a toolbar with a GO sign on one of the buttons. When you click it, I want it to change to a STOP sign. I have both images in the imagelist, but cannot figure out the code to change the GO sign to a STOP sign. Here is what I have:

    If startstop% = 1 Then
    Toolbar1.Buttons(10).ToolTipText = "Start Execution"
    Toolbar1.Buttons(10).Image = ImageList1.ListImages(10)
    ElseIf startstop% = 2 Then
    Toolbar1.ToolTipText = "Stop Execution"
    Toolbar1.Buttons(10).Image = ImageList1.ListImages(14)
    End If

    But this is giving me Run Time error 35603 'Invalid Key'

    What am I doing wrong?? Thanks for any help.

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Why don't you have two toolbar buttons with the different images and make only one visible at a time.

    When one is pressed make it invisible and the other visible.

  3. #3
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    Damn Stevie, just beat me to it!

    //Anders

  4. #4
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Gotta be quick round here mate, happens to me all the time.

  5. #5
    Guest
    You got an Invalid Key error because you did not specify a Key for the ListImage.

    Code:
    Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    
        If Button.Key = "Stop" Then
            Button.Image = ImageList1.ListImages(2).Key
        End If
        
    End Sub

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