更改焦点上文本框的颜色 [英] change color of textbox on focus

查看:82
本文介绍了更改焦点上文本框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


我使用winform。在winform我有3个文本框。文本框的默认颜色是浅蓝色。

但是当文本框是焦点时,颜色应该变为白色,当失去焦点的文本框颜色应该变为原始颜色时。





plz尽快回复

hi
I my using winform. in winform i have 3 textbox. the textbox default color is lightblue.
but when the textbox is focus the color should change to white and when its lost focus textbox color should come to its original color.


plz reply as soon as possible

推荐答案

参考这些链接



更改焦点上的文本框/输入背景颜色 [ ^ ]



如何在onfocus时更改文本框的背景颜色? [ ^ ]


问候..:笑:
Refer to these links

Change Textbox/Input background color on focus[^]

How do i change Background color of textbox when onfocus?[^]

Regards..:laugh:


请尝试以下

最初为所有三个文本框分配默认颜色为浅蓝色

接下来创建两个事件 textBox1_Enter / textBox1_Leave 如下



Please try the following
Initially assign the default color as Light blue for All three text box
next create two events textBox1_Enter/textBox1_Leave as follows

private void textBox1_Enter(object sender, EventArgs e)
       {
           textBox1.BackColor = Color.White;
       }

       private void textBox1_Leave(object sender, EventArgs e)
       {
           textBox1.BackColor = Color.LightBlue;
       }


用于文本框焦点更改事件

use this for textbox focus change event
private void textBox1_Validating(object sender, CancelEventArgs e)
       {
           textBox1.BackColor = System.Drawing.Color.Red;
       }
       private void textBox1_Enter(object sender, EventArgs e)
       {
           textBox1.BackColor = System.Drawing.Color.Yellow;
       }


这篇关于更改焦点上文本框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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