文本框获得焦点事件和失去焦点事件 [英] Textbox Got Focus Event and Lost Focus Event

查看:286
本文介绍了文本框获得焦点事件和失去焦点事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人
我的表单中有很多文本框,我想为
设置代码 文本框失去焦点事件,仅在一行中更改文本框的背景颜色...
请帮我. :((:((<

every one
i have lots of textboxes in my form, i want to set code for
textbox lost focus event that change textbox back color in only one line...
please help me. :(( :((

推荐答案

一种方法-捕获代码中的所有事件.然后,调用使用sender作为参数的通用方法.更改发件人的背景色.

像-

One approach - capture all the events in your code. Then, call a common method which uses the sender as the parameter. Change the back color of the sender.

Something like -

void textBox1_GotFocus(object sender, System.EventArgs e)
{
    CommonColorChangerMethod(sender);
}
void CommonColorChangerMethod(object sender)
{
    ((TextBox)sender).BackColor = ....
}


这篇关于文本框获得焦点事件和失去焦点事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆