当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > WinForm中ToolBar与TabControl的一些事件写法(C#)

ASP.NET
HTML服务器控件介绍:HtmlInputFile控件
HTML服务器控件介绍:HtmlInputHidden控件
HTML服务器控件介绍:HtmlInputImage控件
HTML服务器控件介绍:HtmlInputRadioButton控件
HTML服务器控件介绍:HtmlInputText控件
HTML服务器控件介绍:HtmlSelect控件
HTML服务器控件介绍:HtmlTable控件
HTML服务器控件介绍:HtmlTableCell控件
HTML服务器控件介绍:HtmlTableRow控件
HTML服务器控件介绍:HtmlTextArea控件
Web服务器控件:AdRotator控件
Web服务器控件:Button控件
Web服务器控件:Calendar控件
Web服务器控件:CheckBox控件
Web服务器控件:CheckBoxList控件
Web服务器控件:DropDownList控件
Web服务器控件:HyperLink控件
Web服务器控件:Image控件
Web服务器控件:ImageButton控件
Web服务器控件:Label控件

ASP.NET 中的 WinForm中ToolBar与TabControl的一些事件写法(C#)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 249 ::
收藏到网摘: n/a


由于ToolBar控件中不提供单个按钮的事件,因此在这里利用toolBar1.Buttons集合的IndexOf()方法捕捉单个的按钮,将其事件发送给ToolBarButtonClickEventHandler处理器。
//初始化:以下是代码片段:this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//事件方法:以下是代码片段:private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { switch(toolBar1.Buttons.IndexOf(e.Button)) { case 0: MessageBox.Show("this is tButton1"); break; case 1: MessageBox.Show("this is tButton2"); break; } }
——————————在TabControl控件中并没提供单个选项卡的Click事件,今天下午翻了翻MSDN 结果还是没找到相关的文档:( 看来只有自个儿折腾了...还好有个SelectedIndexChanged事件为我所用:)
以下是代码片段:private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { switch(this.tabControl1.SelectedIndex) { case 0: MessageBox.Show("tabPage1 is Selected"); break; case 1: MessageBox.Show("tabPage2 is Selected"); break; } }