更改具有焦点的控件的背景颜色 [英] change backcolor of controls which have focus
本文介绍了更改具有焦点的控件的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
只是一种新手问题。
我怎样才能改变焦点对照的背景颜色
( textbox / combobox / datetimepicker)和
当它们失去焦点时将它设置为白色。
提前预付
Stefan
hello,
Just a sort of newbie question.
How can i change the backcolor of the controls which have the focus
(textbox/combobox/datetimepicker) and
set it back to white when they lost focus.
thanx in advance
Stefan
推荐答案
使用这些事件:
Private Sub Button1_GotFocus(ByVal sender As Object,ByVal e As
System.EventArgs)处理Button1.GotFocus
Button1.BackColor = .....
End Sub
Private Sub Button1_LostFocus(ByVal发送者作为对象,ByVal e As
System.EventArgs)处理Button1.LostFocus
Button1.BackColor = .....
End Sub
希望它有所帮助
克里斯
" Stefan" < st@nospam.com>在消息中写道
news:uM ************** @ TK2MSFTNGP12.phx.gbl ...
Use these events:
Private Sub Button1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.GotFocus
Button1.BackColor = .....
End Sub
Private Sub Button1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.LostFocus
Button1.BackColor = .....
End Sub
Hope it helps
Chris
"Stefan" <st@nospam.com> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
你好,>只是一种新手问题。
如何更改具有焦点的控件的背景颜色(textbox / combobox / datetimepicker)和
在失去焦点时将其设置为白色。
thanx提前
Stefan
hello,
Just a sort of newbie question.
How can i change the backcolor of the controls which have the focus
(textbox/combobox/datetimepicker) and
set it back to white when they lost focus.
thanx in advance
Stefan
使用这些活动:
Private Sub Button1_GotFocus(ByVal sender As Object,ByVal e As
System.EventArgs)处理Button1.GotFocus
Button1.BackColor = .....
End Sub
Private Sub Button1_LostFocus(ByVal sender As Object,ByVal e As
System.EventArgs)处理Button1.LostFocus
Button1.BackColor = .....
结束子
希望它有所帮助
克里斯
" Stefan" < st@nospam.com>在消息中写道
news:uM ************** @ TK2MSFTNGP12.phx.gbl ...
Use these events:
Private Sub Button1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.GotFocus
Button1.BackColor = .....
End Sub
Private Sub Button1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.LostFocus
Button1.BackColor = .....
End Sub
Hope it helps
Chris
"Stefan" <st@nospam.com> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
你好,>只是一种新手问题。
如何更改具有焦点的控件的背景颜色(textbox / combobox / datetimepicker)和
在失去焦点时将其设置为白色。
提前预订
Stefan
hello,
Just a sort of newbie question.
How can i change the backcolor of the controls which have the focus
(textbox/combobox/datetimepicker) and
set it back to white when they lost focus.
thanx in advance
Stefan
Stefan,
克里斯建议你可以使用GotFocus& LostFocus事件为此。
为了尽量减少重复的代码,我会考虑使用:
1.所有控件的单个事件处理程序
2.派生控件
3.一个ExtenderProvider(实现System.Component.IExtenderProvider)
#1你需要添加相同的处理程序在每个表单上,加上将所有
控件连接到处理程序。
使用#2,您需要从每个控件中获取&记得使用这些自定义的
控件。
#3更多的工作就是创建Provider本身(然后是单个派生的
控制),然而在多个
表格上使用提供商真的很容易。
我通常赞成#2作为不变的我正在添加其他自定义到
控制......
#2& #3是设计师友好!
希望这有帮助
Jay
" Stefan" < st@nospam.com>在消息中写道
news:uM ************** @ TK2MSFTNGP12.phx.gbl ...
Stefan,
As Chris suggests you can use the GotFocus & LostFocus events for this.
To minimize duplicate code I would consider using:
1. a single event handler for all controls
2. derived controls
3. an ExtenderProvider (implement System.Component.IExtenderProvider)
With #1 you need to add the same "handler" on each form, plus wire all the
controls to the handler.
With #2 you need to derive from every control & remember to use these custom
controls.
With #3 its more work to create the Provider itself (then a single derived
control), however it is then really easy to use the provider on multiple
forms.
I normally favor #2 as invariable I am adding other customizations to the
controls...
Both #2 & #3 are "designer friendly"!
Hope this helps
Jay
"Stefan" <st@nospam.com> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
你好,>只是一种新手问题。
如何更改具有焦点的控件的背景颜色(textbox / combobox / datetimepicker)和
在失去焦点时将其设置为白色。
提前预订
Stefan
hello,
Just a sort of newbie question.
How can i change the backcolor of the controls which have the focus
(textbox/combobox/datetimepicker) and
set it back to white when they lost focus.
thanx in advance
Stefan
这篇关于更改具有焦点的控件的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文