winfrom文本框焦点获取和丢失问题 我在winfrom里有个文本框,然后我想加载上来的时候文本框里有值然后我点击后没有值当我点别的文本框时候这个文本框里的值在回来,我知道是获得焦点和丢失焦点的问题但是我在winfromm里没有找到呀,求助怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public Form2() { InitializeComponent(); this.textBox1.Focus(); this.textBox2.Text = "测试数据"; this.label1.Visible = false; this.textBox2.Enter += new EventHandler(Textbox1_OnFocus); this.textBox2.LostFocus += new EventHandler(Textbox1_LostFocus); } private void Textbox1_OnFocus(object sender, EventArgs e) { //MessageBox.Show("获得焦点"); this.label1.Text = this.textBox2.Text; this.textBox2.Text = ""; } private void Textbox1_LostFocus(object sender, EventArgs e) { //MessageBox.Show("失去焦点"); this.textBox2.Text = this.label1.Text; }具体的例子,你看一下 做一下判断,if(this.label1.Text !=this.textBox2.Text)this.label1.Text = this.textBox2.Text; this.textBox2.Text = ""; 多个线程操作的问题! c#中,怎么能主动让窗口失效进行重绘 如何解析给定的文本中有哪些是类、属性、方法等 C#如何实现拼写检查功能? 如何获取文件相对路径??? 抽象工厂模式 如何动态调用静态属性? 还是treeview问题 主form上的图片如果实现拉伸 紧急求助:用vs.net制作安装程序,怎样获取用户选择的安装路径,并根据路径更新相应的XML配置文件(在线等候) ClickOnce C#程序如何与浏览器通讯 大侠们,求正则表达式!!
public Form2()
{
InitializeComponent();
this.textBox1.Focus();
this.textBox2.Text = "测试数据";
this.label1.Visible = false;
this.textBox2.Enter += new EventHandler(Textbox1_OnFocus);
this.textBox2.LostFocus += new EventHandler(Textbox1_LostFocus);
}
private void Textbox1_OnFocus(object sender, EventArgs e)
{
//MessageBox.Show("获得焦点");
this.label1.Text = this.textBox2.Text;
this.textBox2.Text = "";
}
private void Textbox1_LostFocus(object sender, EventArgs e)
{
//MessageBox.Show("失去焦点");
this.textBox2.Text = this.label1.Text;
}具体的例子,你看一下
if(this.label1.Text !=this.textBox2.Text)
this.label1.Text = this.textBox2.Text;
this.textBox2.Text = "";