基于鼠标移动的文本框背景色. [英] Textbox backcolor based on mouse movement.

查看:77
本文介绍了基于鼠标移动的文本框背景色.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

当我们专注于任何文本框时,我们可以更改背景色.

Dear all,

As we focus on any textbox we can change the background colour.

Private Sub TextBox2_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.GotFocus
       TextBox2.BackColor = Color.GreenYellow
End Sub



指南,如果我们有25个以上的文本框,并且希望通过更改游标来更改所有文本框颜色,或者想通过更改背景色来查看游标的位置,请参见
我有25个以上的文本框,并且如果要通过在其上移动鼠标来更改所有文本框颜色,或者是否想通过更改背景色来查看鼠标的位置.



KINDLY GUIDE IF WE HAVE MORE THAN 25 TEXTBOXES AND WANT TO CHANGE ALL THE TEXTBOX COLUR WITH MOVEMENT OF CURSOR ON THAT OR WANT TO SEE THE LOCATION OF CURSOR WITH CHANGING BACKGROUD COLOUR HOW TO SEE THAT
I have more than 25 textboxes and if I want to change all the textbox color with movement of mouse on that, or if I want to see the location of mouse with changing background color. How to see that?

推荐答案

有这么多的文本框,我将创建一个派生的TextBox控件,如下所示:

With so many textboxes, I would create a derived TextBox control like this:

Public Class SuperTextBox
    Inherits System.Windows.Forms.TextBox

    Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
        Me.BackColor = Color.GreenYellow
        MyBase.OnGotFocus(e)
    End Sub

    Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)
        MyBase.OnLostFocus(e)
        Me.BackColor = SystemColors.Window
    End Sub
End Class



然后,我将所有文本框的类型(在设计器文件中)从System.Windows.Forms.TextBox更改为派生的SuperTextBox类



Then I would change all the textbox''s types (in the designer file) from System.Windows.Forms.TextBox to the derived SuperTextBox class


编写一个通用方法并传入名称文本框.或通过集合跟踪文本框列表.
Write a common method and pass in the name of the textbox. Or track the list of textboxes through a collection.


您可以将下面的属性附加到所有文本框以获得所需的结果,

You can attach the attribute below to all your textbox to get desired result,

onBlur="this.style.backgroundColor='#ffffff'" 


这篇关于基于鼠标移动的文本框背景色.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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