By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,986 Members | 1,522 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,986 IT Pros & Developers. It's quick & easy.

Toolbar control

Ali Rizwan
100+
P: 927
Hi all,
I am using a control named toolbar control.

I have added 5 buttons to it
Now i want to add some commands to button 1
when i add code to toolbar click event then it played on every button
but i want to play that code only on button 1 how can i do

Thanx
Dec 4 '07 #1
Share this Question
Share on Google+
11 Replies


debasisdas
Expert 5K+
P: 8,127
You need to handle the index of the button.
Dec 6 '07 #2

VijaySofist
100+
P: 107
Hi!

In the ToolBar1_Click event use the Select Case statement like

Private Sub ToolBar1_Click()
Select Case ButtonCaption
Case "New"
Call Related Function
Case "Save"
Call Related Function
Else
Call Related Function
End Select
End Sub

With Regards
Vijay. R
Dec 6 '07 #3

debasisdas
Expert 5K+
P: 8,127
Hi!

In the ToolBar1_Click event use the Select Case statement like

Private Sub ToolBar1_Click()
Select Case ButtonCaption
.
.
What if the button has no caption ?
Dec 6 '07 #4

lotus18
100+
P: 866
What if the button has no caption ?
VijaySofist can use toolbar's index.

Rey Sean
Dec 6 '07 #5

debasisdas
Expert 5K+
P: 8,127
VijaySofist can use toolbar's index.

Rey Sean
Thats what i have suggested in my previous post.
Dec 6 '07 #6

Ali Rizwan
100+
P: 927
I have tried all these things
Vijay >>> there are no captions on buttons
Debasis >>>> Can u plz give me an example for using index.

Thanx
Dec 7 '07 #7

9815402440
100+
P: 180
hi

when you insert button in the toolbar (by opening properties by right clicking on it), set Key of each button. then use following code


Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
With Toolbar1
Select Case Button.Key
Case "one"
MsgBox "one"
Case "two"
MsgBox "two"
End Select
End With
End Sub

regards
manpreet singh dhillon hoshiarpur
Dec 8 '07 #8

Ali Rizwan
100+
P: 927
...when you insert button in the toolbar (by opening properties by right clicking on it), set Key ...
Thanks Manpreet
I'll try it and
thanks again.
Dec 9 '07 #9

Expert 5K+
P: 8,434
So, did it work?
Dec 12 '07 #10

QVeen72
Expert 100+
P: 1,445
Hi Ali,

Alternatively, you can check for Button.Index
something like this :

Expand|Select|Wrap|Line Numbers
  1.     Select Case Button.index
  2.         Case 1
  3.             MsgBox "First Button"
  4.         Case 2
  5.             MsgBox "Second Button"
  6.         Case 3
  7.             MsgBox "Third Button"
  8.     End Select
  9.  
Regards
Veena
Dec 12 '07 #11

Ali Rizwan
100+
P: 927
Thanx to all
Specialy to Veena and Manpreet Singh

Problem Solved

Thanx

>> Ali <<
Dec 12 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.