请问输出窗口的name 新建一个form窗口,拖一个button上去,点击按钮, 弹出对话框,显示窗口的name请问,这个点击事件是怎样写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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);} 为什么不可以写成:MessageBox.Show(Form1.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是两个概念Name:窗体名称Text:窗体标题 public partial class Form1 : Form { 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);} this指当前对象,在这里就是指当前的Form,this.button2就是当前窗口的button2……建议你先学学C#的基础吧…… this:表示当前对象,比如在Form1类里新建的对象都可以用this个表示如:按钮,文本框等还有其它类也一样,只要在类里都表示类中成员补充一下:MessageBox.Show(Form1.Text);用法错误:必须先实例化再取值Form1 frm=new Form1();MessageBox.Show(frm.Text); android application qingzhijiao 窗口透明有几种方法? C#串口通信的问题,急! 请教高手 C# 如何写wap网站 WinForm的数据验证在什么事件中写啊? dbhelper 类 与配置文件的集合??? VS.NET(C#.net 或 VB.net)下开发的ACCESS数据库程序,能否让多用户或多个应用程序同时访问(读写操作)一个ACCESS数据库? 请教怎么在不同的form间传递变量 combox 问题 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);