Click here to Skip to main content
15,914,452 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Convert from decimal to hexidecimal? Pin
Dalek Dave30-Apr-10 4:23
professionalDalek Dave30-Apr-10 4:23 
GeneralRe: Convert from decimal to hexidecimal? Pin
DaveAuld30-Apr-10 4:28
professionalDaveAuld30-Apr-10 4:28 
GeneralRe: Convert from decimal to hexidecimal? Pin
Adam Wike1-May-10 13:32
Adam Wike1-May-10 13:32 
QuestionDynamically adding tool strip buttons [modified] Pin
MacRaider430-Apr-10 2:54
MacRaider430-Apr-10 2:54 
AnswerRe: Dynamically adding tool strip buttons Pin
Simon_Whale30-Apr-10 3:17
Simon_Whale30-Apr-10 3:17 
GeneralRe: Dynamically adding tool strip buttons Pin
MacRaider430-Apr-10 3:39
MacRaider430-Apr-10 3:39 
GeneralRe: Dynamically adding tool strip buttons Pin
MacRaider430-Apr-10 3:49
MacRaider430-Apr-10 3:49 
AnswerRe: Dynamically adding tool strip buttons Pin
Wayne Gaylard30-Apr-10 3:56
professionalWayne Gaylard30-Apr-10 3:56 
Hi
You need to add a delegate to the ToolStripButton to handle it's Click event. First create the routines that you want to fire when the user clicks on the button (remember that it must have the same signature as a 'normal' click event handler). For example in your app you could create 2 routines like so

vb/net
Private Sub btnSomething_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

       MsgBox(CType(sender, ToolStripButton).ToolTipText & ", " & CType(sender, ToolStripButton).Text)

   End Sub

   Private Sub btnSomething2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

       MsgBox(CType(sender, ToolStripButton).ToolTipText & ", " & CType(sender, ToolStripButton).Text)

   End Sub


Then when you create the buttons add your delegates like this

VB.NET
'Create a button for the tool strip
Dim btnSomething As New ToolStripButton
btnSomething.Text = "Test 1"
'btnSomething.Image = Image.FromFile("F:\VisualBasic\ToolStripTest\images\eventlog.ico")
btnSomething.TextImageRelation = TextImageRelation.ImageAboveText
btnSomething.ToolTipText = "This is Just a Test"
AddHandler btnSomething.Click, AddressOf btnSomething_Click

Dim btnSomething2 As New ToolStripButton
btnSomething2.Text = "Test 2"
' btnSomething2.Image = Image.FromFile("F:\VisualBasic\ToolStripTest\images\eventlog.ico")
btnSomething2.TextImageRelation = TextImageRelation.ImageAboveText
btnSomething2.ToolTipText = "This is Just a Test again"
AddHandler btnSomething2.Click, AddressOf btnSomething2_Click


'Display a separator with followed by the two created buttons followed by another separator
ToolStrip1.Items.Add(New System.Windows.Forms.ToolStripSeparator)
ToolStrip1.Items.Add(btnSomething)
ToolStrip1.Items.Add(btnSomething2)
ToolStrip1.Items.Add(New System.Windows.Forms.ToolStripSeparator)


then you should get the click events to fire. See thread 2 or 3 down for further example

Happy Coding
GeneralRe: Dynamically adding tool strip buttons Pin
MacRaider430-Apr-10 6:44
MacRaider430-Apr-10 6:44 
GeneralRe: Dynamically adding tool strip buttons Pin
Wayne Gaylard30-Apr-10 15:11
professionalWayne Gaylard30-Apr-10 15:11 
GeneralRe: Dynamically adding tool strip buttons Pin
MacRaider43-May-10 6:30
MacRaider43-May-10 6:30 
QuestionRead data from MS Excel Pin
nishkarsh_k30-Apr-10 2:18
nishkarsh_k30-Apr-10 2:18 
AnswerRe: Read data from MS Excel Pin
Dave Kreskowiak30-Apr-10 4:01
mveDave Kreskowiak30-Apr-10 4:01 
GeneralRe: Read data from MS Excel [modified] Pin
nishkarsh_k3-May-10 2:25
nishkarsh_k3-May-10 2:25 
GeneralRe: Read data from MS Excel Pin
Dave Kreskowiak3-May-10 5:09
mveDave Kreskowiak3-May-10 5:09 
AnswerRe: Read data from MS Excel Pin
Wayne Gaylard30-Apr-10 4:05
professionalWayne Gaylard30-Apr-10 4:05 
GeneralRe: Read data from MS Excel Pin
nishkarsh_k2-May-10 20:28
nishkarsh_k2-May-10 20:28 
GeneralRe: Read data from MS Excel [modified] Pin
nishkarsh_k2-May-10 23:37
nishkarsh_k2-May-10 23:37 
GeneralRe: Read data from MS Excel Pin
Wayne Gaylard3-May-10 0:07
professionalWayne Gaylard3-May-10 0:07 
GeneralRe: Read data from MS Excel Pin
nishkarsh_k3-May-10 2:08
nishkarsh_k3-May-10 2:08 
GeneralRe: Read data from MS Excel Pin
nishkarsh_k4-May-10 3:27
nishkarsh_k4-May-10 3:27 
GeneralRe: Read data from MS Excel Pin
Wayne Gaylard4-May-10 20:44
professionalWayne Gaylard4-May-10 20:44 
GeneralRe: Read data from MS Excel Pin
nishkarsh_k5-May-10 0:28
nishkarsh_k5-May-10 0:28 
GeneralRe: Read data from MS Excel Pin
Wayne Gaylard5-May-10 1:41
professionalWayne Gaylard5-May-10 1:41 
GeneralRe: Read data from MS Excel Pin
nishkarsh_k6-May-10 19:53
nishkarsh_k6-May-10 19:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.