新建一个form窗口,拖一个button上去,点击按钮, 弹出对话框,显示窗口的name
请问,这个点击事件是怎样写
请问,这个点击事件是怎样写
解决方案 »
- 初学C#,求教个问题
- 未能加载文件或程序集“ActiproSoftware.CodeHighlighter.Net20”或它的某一个依赖项。拒绝访问
- 请教个C#服务的问题
- C#中服务端控件的使用:判断
- 请问:如何使用gridView导出excel
- List 泛型类 怎么实现IComparable 泛型接口?
- c#中如何一次执行多条update语句(access数据库)
- 关于DATAGRID的两个问题!!!!
- 怎样从rtf格式文件提取纯文本
- 如何用C#做个边下边播的播放器?好迷茫啊
- Form2打开的串口,Form2.hide之后,再用串口时提示已经关闭,为啥
- for/foreach 循环编译器报错问题?
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this.Name);
}
public Form1()
{
InitializeComponent();
this.button1.Click += new EventHandler(button1_Click);
}private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this.Text);
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this.Name);
}
}测试已通过编译!
新建一个form窗口,拖2个button上去,点击button1按钮, 弹出对话框,显示button2的name
请问,这个点击事件是怎样写
Name:窗体名称
Text:窗体标题
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this.button2.Name);
}
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this.button2.Name);
}
建议你先学学C#的基础吧……
如:按钮,文本框等
还有其它类也一样,只要在类里都表示类中成员
补充一下:MessageBox.Show(Form1.Text);
用法错误:
必须先实例化再取值
Form1 frm=new Form1();
MessageBox.Show(frm.Text);