好像在click时间里可以得到button对象,不知你要什么
解决方案 »
- C# 安装包中运行SQLEXPR_CHS_2005.EXE文件运行到检查环境时,进程退出,无法进行安装,求解决之道,万分感谢!!
- 【新手问个蠢问题】VS2008里面有多个WEB网站项目如何只启动调试其中一个?
- 如何去注册多个TCP/HTTP通道 ?
- 谁有sharpdevelop的实例教程?
- 请问 VS 2005 正式版发布了吗?
- 高手请做答,在MDI窗体中,数据需要与主(父)窗体交互,在主窗体显示子窗体的加载进度,(进度条在主窗体中)如何实现,谢谢,在线等!
- 很高难度,请求各位高手帮忙!
- 调用方法是否会改变原来的值
- finding:ActiveReports for .NET professional
- 构造函数和析构函数到底是怎么回事?
- 怎样才能知道一条记录是DataView中的第一条记录或最后一条记录??
- 如何强制退出程序,在没有运行Application.Run的情况下
protected void toolBar1_ButtonClick (
Object sender,
ToolBarButtonClickEventArgs e)
{
// Evaluate the Button property to determine which button was clicked.
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0:
openFileDialog1.ShowDialog();
// Insert code to open the file.
break;
case 1:
saveFileDialog1.ShowDialog();
// Insert code to save the file.
break;
case 2:
printDialog1.ShowDialog();
// Insert code to print the file.
break;
}
}
ms-help://MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemWindowsFormsToolBarClassTopic.htm
private void toolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
{
if(e.Button == this.toolBarButton1)
{
...
}
else if(e.Button == this.toolBarButton2)
{
...
}
...
}
FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
for (int i=0;i<fields.Length;i++)
{ if (fields[i].FieldType.Name == "ToolBarButton")
{
ToolBarButton button = (ToolBarButton)fields[i].GetValue(this);
if (e.Button.Equals(button))
{
MessageBox.Show(fields[i].Name);
break;
}
}
}这种方法是最好的