List
Private Sub
ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal
e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
ToolBar1.ButtonClick
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0
txtMsg.Text = "Excellent - you got an A"
Case 1
txtMsg.Text = "Very good - you got a B"
Case 2
txtMsg.Text = "OK - you got a C"
Case 3
txtMsg.Text = "Need to work harder - you got a
D"
End Select
End Sub
Imagelist1
Private Sub
ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal
e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
ToolBar1.ButtonClick
Select Case CStr(e.Button.Tag)
Case Is = "A"
txtMsg.Text = "Excellent - you got an A"
Case Is = "B"
txtMsg.Text = "Very good - you got a B"
Case Is = "C"
txtMsg.Text = "OK - you got a C"
Case Is = "D"
txtMsg.Text
= "Need to work harder - you got a D"
Case Is = "F"
txtMsg.Text = "Hope you try again - you got a
F"
End Select
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnDelete.Click
If rbnA.Checked = True And
ToolBar1.Buttons.Contains(tbrGradeA) Then
ToolBar1.Buttons.Remove(tbrGradeA)
End If
If rbnB.Checked = True And
ToolBar1.Buttons.Contains(tbrGradeB) Then
ToolBar1.Buttons.Remove(tbrGradeB)
End If
If rbnC.Checked = True And
ToolBar1.Buttons.Contains(tbrGradeC) Then
ToolBar1.Buttons.Remove(tbrGradeC)
End If
If rbnD.Checked = True And
ToolBar1.Buttons.Contains(tbrGradeD) Then
ToolBar1.Buttons.Remove(tbrGradeD)
End If
If rbnF.Checked = True And
ToolBar1.Buttons.Contains(tbrGradeF) Then
ToolBar1.Buttons.Remove(tbrGradeF)
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnAdd.Click
If rbnA.Checked = True And Not ToolBar1.Buttons.Contains(tbrGradeA) Then
ToolBar1.Buttons.Add(tbrGradeA)
End If
If rbnB.Checked = True And Not ToolBar1.Buttons.Contains(tbrGradeB) Then
ToolBar1.Buttons.Add(tbrGradeB)
End If
If rbnC.Checked = True And Not ToolBar1.Buttons.Contains(tbrGradeC) Then
ToolBar1.Buttons.Add(tbrGradeC)
End If
If rbnD.Checked = True And Not ToolBar1.Buttons.Contains(tbrGradeD) Then
ToolBar1.Buttons.Add(tbrGradeD)
End If
If rbnF.Checked = True And Not ToolBar1.Buttons.Contains(tbrGradeF) Then
ToolBar1.Buttons.Add(tbrGradeF)
End If
End Sub
End Class
Like Control Array
Private Sub AllButtons_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnOne.Click, btnTwo.Click, btnThree.Click
Dim i As Integer
Select Case sender.TabIndex
Case 0
txtWhich.Text = "You selected Button One"
Case 1
txtWhich.Text = "You selected Button Two"
Case 2
txtWhich.Text = "You selected Button
Three"
End Select
For i = 0 To 2
If sender.TabIndex = i Then
txtCheck.Text = "The button was " & CStr(sender.TabIndex + 1)
End If
Next
Select Case sender.tag
Case "one"
txtWhichTag.Text = "You selected Button One"
Case "two"
txtWhichTag.Text = "You selected Button
Two"
Case "three"
txtWhichTag.Text = "You selected Button
Three"
End Select
End Sub
End Class