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 13 6865
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... 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
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... 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,
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... 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,
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... 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,
When you use this class in your application
\\\
Public Class MyBackGroundColors
Public Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
AddHandler ctr.LostFocus, AddressOf meLostFocus
AddHandler ctr.GotFocus, AddressOf meGotFocus
doSet(ctr)
Next
End Sub
Private Sub meLostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Control).BackColor = SystemColors.Window
End Sub
Private Sub meGotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Control).BackColor = Color.LightBlue
End Sub
End Class
////
And than this row in every load event of your startupforms.
\\\
Dim mycol As New MyBackGroundColors
mycol.doSet(Me)
Dim frm1 As New Form2
mycol.doSet(frm1) 'and than this for every form you create.
frm1.Show()
////
Than I think you have done it for every form and all your controls.
I hope this helps?
Cor
Stefan,
When you use this class in your application
\\\
Public Class MyBackGroundColors
Public Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
AddHandler ctr.LostFocus, AddressOf meLostFocus
AddHandler ctr.GotFocus, AddressOf meGotFocus
doSet(ctr)
Next
End Sub
Private Sub meLostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Control).BackColor = SystemColors.Window
End Sub
Private Sub meGotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Control).BackColor = Color.LightBlue
End Sub
End Class
////
And than this row in every load event of your startupforms.
\\\
Dim mycol As New MyBackGroundColors
mycol.doSet(Me)
Dim frm1 As New Form2
mycol.doSet(frm1) 'and than this for every form you create.
frm1.Show()
////
Than I think you have done it for every form and all your controls.
I hope this helps?
Cor
how can i prevent with your solutions buttons
get coloured to. now i'm using the tag property
For Each ctr In parentCtr.Controls
if ctr.tag.tostring <> 'btn' then AddHandler ctr.LostFocus, AddressOf meLostFocus AddHandler ctr.GotFocus, AddressOf meGotFocus doSet(ctr)
end if Next
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:OM**************@tk2msftngp13.phx.gbl... Stefan,
When you use this class in your application \\\ Public Class MyBackGroundColors Public Sub doSet(ByVal parentCtr As Control) Dim ctr As Control For Each ctr In parentCtr.Controls AddHandler ctr.LostFocus, AddressOf meLostFocus AddHandler ctr.GotFocus, AddressOf meGotFocus doSet(ctr) Next End Sub Private Sub meLostFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) DirectCast(sender, Control).BackColor = SystemColors.Window End Sub Private Sub meGotFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) DirectCast(sender, Control).BackColor = Color.LightBlue End Sub End Class //// And than this row in every load event of your startupforms. \\\ Dim mycol As New MyBackGroundColors mycol.doSet(Me) Dim frm1 As New Form2 mycol.doSet(frm1) 'and than this for every form you create. frm1.Show() //// Than I think you have done it for every form and all your controls.
I hope this helps?
Cor
how can i prevent with your solutions buttons
get coloured to. now i'm using the tag property
For Each ctr In parentCtr.Controls
if ctr.tag.tostring <> 'btn' then AddHandler ctr.LostFocus, AddressOf meLostFocus AddHandler ctr.GotFocus, AddressOf meGotFocus doSet(ctr)
end if Next
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:OM**************@tk2msftngp13.phx.gbl... Stefan,
When you use this class in your application \\\ Public Class MyBackGroundColors Public Sub doSet(ByVal parentCtr As Control) Dim ctr As Control For Each ctr In parentCtr.Controls AddHandler ctr.LostFocus, AddressOf meLostFocus AddHandler ctr.GotFocus, AddressOf meGotFocus doSet(ctr) Next End Sub Private Sub meLostFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) DirectCast(sender, Control).BackColor = SystemColors.Window End Sub Private Sub meGotFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) DirectCast(sender, Control).BackColor = Color.LightBlue End Sub End Class //// And than this row in every load event of your startupforms. \\\ Dim mycol As New MyBackGroundColors mycol.doSet(Me) Dim frm1 As New Form2 mycol.doSet(frm1) 'and than this for every form you create. frm1.Show() //// Than I think you have done it for every form and all your controls.
I hope this helps?
Cor
Stefan,
It is easier to use
\\\
If Not TypeOf ctr Is Button then .........
///
I hope this helps?
Cor
Stefan,
It is easier to use
\\\
If Not TypeOf ctr Is Button then .........
///
I hope this helps?
Cor
thanx
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:OE**************@TK2MSFTNGP11.phx.gbl... Stefan,
It is easier to use \\\ If Not TypeOf ctr Is Button then ......... ///
I hope this helps?
Cor
thanx
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:OE**************@TK2MSFTNGP11.phx.gbl... Stefan,
It is easier to use \\\ If Not TypeOf ctr Is Button then ......... ///
I hope this helps?
Cor
I use Cor's solution.It works fine
thanks to everyone for responding so quick.
greetz,
Stefan
"Stefan" <st@nospam.com> schreef in bericht
news:uM**************@TK2MSFTNGP12.phx.gbl... 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Smith Duggan |
last post by:
I am attempting to change the background properties of a rectangle in
the code, and have been stuck now for a day and a half. This is my
first access app. Please be gentle with my steaming pile...
|
by: Stefan |
last post by:
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...
|
by: Agnes |
last post by:
I had created a textbox usercontrol , My aim is "once the textbox got focus,
its backcolor become lightgray", lost focus will change back to
default.Please be kind to help.
Private Sub...
|
by: Jim in Arizona |
last post by:
I have a gridview that's being populated from an access db query. The
problem I'm having is that the date/time fields in access that are
populating the gridview are showing both date and time, when...
|
by: garyusenet |
last post by:
I'm using krypton toolkit which has allowed me to make a cool looking
form. However, when I set my textbox to disabled it is 'greyed' out.
The grey colour isn't in keeping with the office 2007...
|
by: windy |
last post by:
I would like to change the backcolor inside the checkbox when the component
is on focus, not the color of the text.
Thanks a lot.
|
by: Rob |
last post by:
hi,
in a form with multiple text and comboboxes , i want change the color of
the bacground if the control has the focus. If the control is an combox i
want also force a dropdown . Can i get...
|
by: Rob |
last post by:
Hi,
I'am working with vb2005 and it's an ADO application based on an access
database.
i'am still have problems to get the backcolor of an control in a different
color if it has the focus.
I am...
|
by: J Lagos |
last post by:
I want to change the backcolor of textboxes in a report depending on their
value.
I messed with this for a few hours but I'm not savvy with the syntax for
getting at controls in a report.
can...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |