如下:两个按钮设置的一摸一样,除了名字不一样。为什么按第一个会正常出现消息,另一个就没反应。难道还有其他的不同吗?知道的教教我啊,谢谢using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 测试按钮控件
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//显示测试按钮DialogResult属性的对话框
private void button1_Click(object sender, EventArgs e)
{ MessageBox.Show("对话框的返回结果为:");
} private void btnDisDlg_Click(object sender, EventArgs e)
{ MessageBox.Show("对话框的返回结果为:");
} private void groupBox1_Enter(object sender, EventArgs e)
{ } }
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 测试按钮控件
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//显示测试按钮DialogResult属性的对话框
private void button1_Click(object sender, EventArgs e)
{ MessageBox.Show("对话框的返回结果为:");
} private void btnDisDlg_Click(object sender, EventArgs e)
{ MessageBox.Show("对话框的返回结果为:");
} private void groupBox1_Enter(object sender, EventArgs e)
{ } }
}
解决方案 »
- DataList未显示出来
- 窗体上有几个按钮,按方向键似乎不同的按钮获取焦点,而winform 中窗体的KeyDown事件为什么不能触发呀?
- 数据库连接是这样的,每当我在页面上使用两个以上的SqlDataReader时,就已有打开的与此命令相关联的 DataReader,必须首先将它关闭 急!
- 请问怎么把TreeView的数据以XML文档的形式导出???
- c#编程
- C#中怎么判断是软驱,硬盘还是光驱呢?
- 如何把Unix下的时间戳(timestamp)转化为DateTime类型??
- 请问C#里面有没有和以前VS 6.0中的MS FlexGrid类似的控件?
- 怎么在窗口中画点?????
- 如何将html化成c#再读取josn格式的值
- 送分,在线急等!有做过移动MISC1.6订购通知接口的望指教
- c#如何调用mspaint
this.button1.Click += new System.EventHandler(this.button1_Click);
this.btnDisDlg.Click += new System.EventHandler(this.btnDisDlg_Click);
public Form1()
{
InitializeComponent();
btnDisDlg.Click += btnDisDlg_Click; //<---
}
如果是.net1.1 的话this.btnDisDlg.Click += new System.EventHandler(this.btnDisDlg_Click); 是在cs文件的InitComponent方法里面的
也可以
1. 双击按钮,看是否跳到要执行的代码处 OR 自动生成代码
2. “查看设计器” 下,看一下这个按钮的Click事件是否设置上