private void Form1_Load(object sender, EventArgs e)
{
Button btn = new Button();
btn.Text = "清空";
btn.Name = "btn1";
btn.Location = new Point(100,100);
this.Controls.Add(btn);
TextBox txt = new TextBox();
txt.Text = "123";
txt.Name = "txt1";
txt.Location = new Point(200,100);
this.Controls.Add(txt);
}
这样在程序运行以后会生成一个按钮和一个文本框~ 现在我想在点击按钮的时候 清空文本框中的内容~ 现在的问题是:在程序没有运行的时候是没有控件的,也没有控件的名字~无法对文本框的内容作清空的处理` 尝试过写一个自定义的事件~ 当点击按钮的时候去调用~ 可是在事件还是无法去获得文本的内容 不知道如何清空` 我们的两个总经理都是外行`不懂语言~是做餐饮方面的`用的是C#写的软件~天天逼我写~我能力有限~真不知道这个问题怎么解决`请大家帮帮忙~ 解决就结贴~~
{
Button btn = new Button();
btn.Text = "清空";
btn.Name = "btn1";
btn.Location = new Point(100,100);
this.Controls.Add(btn);
TextBox txt = new TextBox();
txt.Text = "123";
txt.Name = "txt1";
txt.Location = new Point(200,100);
this.Controls.Add(txt);
}
这样在程序运行以后会生成一个按钮和一个文本框~ 现在我想在点击按钮的时候 清空文本框中的内容~ 现在的问题是:在程序没有运行的时候是没有控件的,也没有控件的名字~无法对文本框的内容作清空的处理` 尝试过写一个自定义的事件~ 当点击按钮的时候去调用~ 可是在事件还是无法去获得文本的内容 不知道如何清空` 我们的两个总经理都是外行`不懂语言~是做餐饮方面的`用的是C#写的软件~天天逼我写~我能力有限~真不知道这个问题怎么解决`请大家帮帮忙~ 解决就结贴~~
解决方案 »
- 请问,ReadLine方法读取文件
- C# 如何更新或者改变List<string>对象ss中的ss[2]的值
- 请教如何让一个链接做按钮
- 太平洋信息系统工程(西安)有限公司笔试题 。netc#
- 简单的多线程编程问题
- Graphics.DrawString的问题,如何让他以字符为单位换行,而不是单词
- WIN2003刚安装完ISS6.0出现Service Unavailable问题
- Win32 多线程处理的问题
- 如何实现DirectoryInfo.GetFiles("*.txt|*.html|*.asm")只获取指定目录下的多个文件扩展名
- winform操作word文档时提示没有足够的存储完成此操作。
- ,.NET是什么时候判断程序集是否已经加载的?
- bindingNavigator插入新记录问题
{
Button btn = new Button();
btn.Text = "清空";
btn.Name = "btn1";
btn.Location = new Point(100, 100);
btn.Click += new EventHandler(btn_Click);
this.Controls.Add(btn);
TextBox txt = new TextBox();
txt.Text = "123";
txt.Name = "txt1";
txt.Location = new Point(200, 100);
this.Controls.Add(txt); } void btn_Click(object sender, EventArgs e)
{
((TextBox)this.Controls["txt1"]).Text = "";
}
{
Button btn = new Button();
btn.Text = "清空";
btn.Name = "btn1";
btn.Location = new Point(100,100);
this.Controls.Add(btn);
btn.Click+=new EventHandler(btn_Click);
TextBox txt = new TextBox();
txt
txt.Text = "123";
txt.Name = "txt1";
txt.Location = new Point(200,100);
this.Controls.Add(txt);
}
void btn_Click(object sender,EventArgs e)
{
...
}...很少写WINFORM
发表于:2008-08-27 17:02:102楼 得分:0
C# code private void Form1_Load(object sender, EventArgs e)
{
Button btn = new Button();
btn.Text = "清空";
btn.Name = "btn1";
btn.Location = new Point(100, 100);
btn.Click += new EventHandler(btn_Click);
this.Controls.Add(btn);
TextBox txt = new TextBox();
txt.Text = "123";
txt.Name = "txt1";
txt.Location = new Point(200, 100);
this.Controls.Add(txt); } void btn_Click(object sender, EventArgs e)
{
((TextBox)this.Controls["txt1"]).Text = "";
}
这个就行