主题:大家能帮我看看代码怎样改才完整?
Temiral
[专家分:50] 发布于 2005-09-11 21:08:00
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
'工具栏各个按钮的事件代码
Dim bn1 As New ToolBarButton
Dim bn2 As New ToolBarButton
Dim bn3 As New ToolBarButton
Select Case ?
Case ToolBarButton1
AxWindowsMediaPlayer1.Ctlcontrols.play()'点击按钮实现播放功能
Case ToolBarButton2()
AxWindowsMediaPlayer1.Ctlcontrols.pause()'点击按钮实现暂停功能
Case ToolBarButton3
AxWindowsMediaPlayer1.Ctlcontrols.stop()'点击按钮实现停止功能
End Select
End Sub
回复列表 (共4个回复)
沙发
ryowu [专家分:6470] 发布于 2005-09-12 12:18:00
ToolBar1.Button.Text
每个case判断text是什么,比如
case "播放":
板凳
Temiral [专家分:50] 发布于 2005-09-13 11:07:00
谢谢给了我一个提示!
3 楼
caichunxia [专家分:20] 发布于 2006-03-22 10:47:00
是这样改的
例如:
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0
Me.Menuxianjin_Click(sender, e)
Case 1
Me.Menuzhuanzhang_Click(sender, e)
Case 2
Me.Menudianfei_Click(sender, e)
Case 3
Me.Menutuichu_Click(sender, e)
Case 4
Me.Menubendanweizhanghao_Click(sender, e)
Case 5
Me.Menukehuxinxi_Click(sender, e)
Case 6
Me.Menukehuchaxun_Click(sender, e)
Case 7
Me.Menuruanjiandeyonhu_Click(sender, e)
End Select
是用它的索引来遍历
4 楼
caichunxia [专家分:20] 发布于 2006-03-22 10:50:00
具体是这样的:
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
'工具栏各个按钮的事件代码
Dim bn1 As New ToolBarButton
Dim bn2 As New ToolBarButton
Dim bn3 As New ToolBarButton
toolbar1.buttons.add(bn1 )
toolbar1.buttons.add(bn2 )
toolbar1.buttons.add(bn3 )
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0
AxWindowsMediaPlayer1.Ctlcontrols.play()'点击按钮实现播放功能
Case 1
AxWindowsMediaPlayer1.Ctlcontrols.pause()'点击按钮实现暂停功能
Case 2
AxWindowsMediaPlayer1.Ctlcontrols.stop()'点击按钮实现停止功能
End Select
End Sub
我来回复