473,416 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

backcolor

Rob
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 searching for a routine which automacticly highligt the control
(textbox, cbo, groupbox) if he is focused instead to program each control
separatly by gotfocus and lostfocus. (Me.BackColor = Color.YellowGreen)

IS there somebody who can help me through this problem ??

regard, rob

Jun 27 '08 #1
5 1833
Rob,

This is very simple to do in VB, be aware that some controls don't have a
backcolor.

\\\
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.GotFocus, ListBox1.GotFocus, TextBox1.GotFocus
DirectCast(sender, Control).BackColor = Color.DarkRed
End Sub

Private Sub MyControls_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.LostFocus, ListBox1.LostFocus,
TextBox1.LostFocus
DirectCast(sender, Control).BackColor = Color.DarkGreen
End Sub
///

Did you know that a better newsgroup to ask this kind of question for VB is
microsoft.public.dotnet.languages.vb

Succes

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ef****************@TK2MSFTNGP03.phx.gbl...
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 searching for a routine which automacticly highligt the control
(textbox, cbo, groupbox) if he is focused instead to program each control
separatly by gotfocus and lostfocus. (Me.BackColor = Color.YellowGreen)

IS there somebody who can help me through this problem ??

regard, rob
Jun 27 '08 #2
Rob
Hi,

it seems my vb does not recognize the names of the controls. he underscore
the name of the controls
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _

Handles ComboBox1.GotFocus, ListBox1.GotFocus, TextBox1.GotFocus

DirectCast(sender, Control).BackColor = Color.DarkRed

End Sub

If i see it right i've to put the name of each control separatly after the
handels. I 've to much controls to achieve this. is it posible to handels
mycontrols.gotfocus instead ?

mvg Rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:98**********************************@microsof t.com...
Rob,

This is very simple to do in VB, be aware that some controls don't have a
backcolor.

\\\
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.GotFocus, ListBox1.GotFocus, TextBox1.GotFocus
DirectCast(sender, Control).BackColor = Color.DarkRed
End Sub

Private Sub MyControls_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.LostFocus, ListBox1.LostFocus,
TextBox1.LostFocus
DirectCast(sender, Control).BackColor = Color.DarkGreen
End Sub
///

Did you know that a better newsgroup to ask this kind of question for VB
is
microsoft.public.dotnet.languages.vb

Succes

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ef****************@TK2MSFTNGP03.phx.gbl...
>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 searching for a routine which automacticly highligt the control
(textbox, cbo, groupbox) if he is focused instead to program each control
separatly by gotfocus and lostfocus. (Me.BackColor = Color.YellowGreen)

IS there somebody who can help me through this problem ??

regard, rob

Jun 27 '08 #3
Rob,

As you have a question, then please make it clear in one time.
There is not any problem to set a ton of controls that should be handled at
the metode.

You can of course as well use the more retro like method as with delegates
to set addresses at a windows message that tells which method should be
handled. (You can even use delegates as you want that).

Something like

\\\
For each ctrl in controls
addhandler ctr.lostfocus, addressOf MyControls_LostFoscus
addhandler ctr.gotfocus, addressOfMycontrols_Gotfocus
next
///

Be aware that if you have controls in a groupbox, a panel or any other
control you have to do this recursive.

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ux**************@TK2MSFTNGP04.phx.gbl...
Hi,

it seems my vb does not recognize the names of the controls. he underscore
the name of the controls
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _

Handles ComboBox1.GotFocus, ListBox1.GotFocus, TextBox1.GotFocus

DirectCast(sender, Control).BackColor = Color.DarkRed

End Sub

If i see it right i've to put the name of each control separatly after the
handels. I 've to much controls to achieve this. is it posible to handels
mycontrols.gotfocus instead ?

mvg Rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:98**********************************@microsof t.com...
>Rob,

This is very simple to do in VB, be aware that some controls don't have a
backcolor.

\\\
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.GotFocus, ListBox1.GotFocus,
TextBox1.GotFocus
DirectCast(sender, Control).BackColor = Color.DarkRed
End Sub

Private Sub MyControls_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.LostFocus, ListBox1.LostFocus,
TextBox1.LostFocus
DirectCast(sender, Control).BackColor = Color.DarkGreen
End Sub
///

Did you know that a better newsgroup to ask this kind of question for VB
is
microsoft.public.dotnet.languages.vb

Succes

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ef****************@TK2MSFTNGP03.phx.gbl...
>>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 searching for a routine which automacticly highligt the control
(textbox, cbo, groupbox) if he is focused instead to program each
control separatly by gotfocus and lostfocus. (Me.BackColor =
Color.YellowGreen)

IS there somebody who can help me through this problem ??

regard, rob

Jun 27 '08 #4
Rob
Hi Cor,

is am a beginner to program in vb and also my english is not as fluent as i
would be , but never the less I try to improve my english.
About the code you wrote, if i put this code into the load of a form I get
an error tells me that "addressOfMycontrols_Gotfocus" is not declared.

what do you mean by "if you have controls in a groupbox, a panel or any
other
control you have to do this recursive."
Most of my controls are been ordened into tabpage and groupboxes !

mvg Rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:2F**********************************@microsof t.com...
Rob,

As you have a question, then please make it clear in one time.
There is not any problem to set a ton of controls that should be handled
at the metode.

You can of course as well use the more retro like method as with
delegates to set addresses at a windows message that tells which method
should be handled. (You can even use delegates as you want that).

Something like

\\\
For each ctrl in controls
addhandler ctr.lostfocus, addressOf MyControls_LostFoscus
addhandler ctr.gotfocus, addressOfMycontrols_Gotfocus
next
///

Be aware that if you have controls in a groupbox, a panel or any other
control you have to do this recursive.

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ux**************@TK2MSFTNGP04.phx.gbl...
>Hi,

it seems my vb does not recognize the names of the controls. he
underscore the name of the controls
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _

Handles ComboBox1.GotFocus, ListBox1.GotFocus,
TextBox1.GotFocus

DirectCast(sender, Control).BackColor = Color.DarkRed

End Sub

If i see it right i've to put the name of each control separatly after
the handels. I 've to much controls to achieve this. is it posible to
handels mycontrols.gotfocus instead ?

mvg Rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:98**********************************@microso ft.com...
>>Rob,

This is very simple to do in VB, be aware that some controls don't have
a backcolor.

\\\
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.GotFocus, ListBox1.GotFocus,
TextBox1.GotFocus
DirectCast(sender, Control).BackColor = Color.DarkRed
End Sub

Private Sub MyControls_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.LostFocus, ListBox1.LostFocus,
TextBox1.LostFocus
DirectCast(sender, Control).BackColor = Color.DarkGreen
End Sub
///

Did you know that a better newsgroup to ask this kind of question for VB
is
microsoft.public.dotnet.languages.vb

Succes

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ef****************@TK2MSFTNGP03.phx.gbl.. .
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 searching for a routine which automacticly highligt the control
(textbox, cbo, groupbox) if he is focused instead to program each
control separatly by gotfocus and lostfocus. (Me.BackColor =
Color.YellowGreen)

IS there somebody who can help me through this problem ??

regard, rob



Jun 27 '08 #5

Rob,

My English is too not as fluent as I wish it would be.

However you and I are not the only ones, I see people which are from
countries where they use English writting crapy too.

(there is a Dutch developper newsgroup, but in that is only one person
active).

However, as you are a beginner than just start with adding the events to the
procedures.

A control is added always to its parent control from which the form is
mostly the top.

Form.Controls
contains by instance
Groubbox.controls
contains by instance
Textbox1

You have to go through all those controls what is the most simple done
recursevily

A sample
http://www.vb-tips.com/ClearTextBox.aspx
>>an error tells me that "addressOfMycontrols_Gotfocus" is not declared.
addressOf MyControls_Gotfocus 'as in my previous sample.
The second one is a simple typo.

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:OL**************@TK2MSFTNGP05.phx.gbl...
Hi Cor,
>
what do you mean by "if you have controls in a groupbox, a panel or any
other
>control you have to do this recursive."

Most of my controls are been ordened into tabpage and groupboxes !

mvg Rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:2F**********************************@microsof t.com...
>Rob,

As you have a question, then please make it clear in one time.
There is not any problem to set a ton of controls that should be handled
at the metode.

You can of course as well use the more retro like method as with
delegates to set addresses at a windows message that tells which method
should be handled. (You can even use delegates as you want that).

Something like

\\\
For each ctrl in controls
addhandler ctr.lostfocus, addressOf MyControls_LostFoscus
addhandler ctr.gotfocus, addressOfMycontrols_Gotfocus
next
///

Be aware that if you have controls in a groupbox, a panel or any other
control you have to do this recursive.

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ux**************@TK2MSFTNGP04.phx.gbl...
>>Hi,

it seems my vb does not recognize the names of the controls. he
underscore the name of the controls
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _

Handles ComboBox1.GotFocus, ListBox1.GotFocus,
TextBox1.GotFocus

DirectCast(sender, Control).BackColor = Color.DarkRed

End Sub

If i see it right i've to put the name of each control separatly after
the handels. I 've to much controls to achieve this. is it posible to
handels mycontrols.gotfocus instead ?

mvg Rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:98**********************************@micros oft.com...
Rob,

This is very simple to do in VB, be aware that some controls don't have
a backcolor.

\\\
Private Sub MyControls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.GotFocus, ListBox1.GotFocus,
TextBox1.GotFocus
DirectCast(sender, Control).BackColor = Color.DarkRed
End Sub

Private Sub MyControls_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.LostFocus, ListBox1.LostFocus,
TextBox1.LostFocus
DirectCast(sender, Control).BackColor = Color.DarkGreen
End Sub
///

Did you know that a better newsgroup to ask this kind of question for
VB is
microsoft.public.dotnet.languages.vb

Succes

Cor
"Rob" <RO*@sdmlfk.nlschreef in bericht
news:ef****************@TK2MSFTNGP03.phx.gbl. ..
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 searching for a routine which automacticly highligt the control
(textbox, cbo, groupbox) if he is focused instead to program each
control separatly by gotfocus and lostfocus. (Me.BackColor =
Color.YellowGreen)
>
IS there somebody who can help me through this problem ??
>
regard, rob
>
>
>

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: perspolis | last post by:
HI I created a user control and place some control on it. I need when I change BackColor of user control,Back Color of other controls also change.. I used foloowing code: public override Color...
6
by: LU | last post by:
A)I build a datagrid based on a calendar date selection. B)When user clicks a button column on the datagrid I want to highlight this row. I use the code below to highlight the row. ***** CODE...
1
by: Firewalker | last post by:
I am attempting to change the backColor property on the previously instantiated buttons FROM a listbox_doubleClick event. I thought it would be something like this: If...
4
by: ray well | last post by:
in my app i need to make a RichTextbox control transparent. i need it to be a like a pane of glass lying on a sheet of paper, where u can see everything on the sheet of paper not covered by text...
3
by: senfo | last post by:
I developed a Windows control in VS 2005 that inherits from the PictureBox Control that adds the ability to select images in a Windows application. It is, however, experiencing a strange issue...
0
by: Wolfgrin | last post by:
Hi, I have set up a report In Access 2003 where there are 2 check boxes I refer to to change the color of the Date of that record. That part is working. I also need to Change the color of the...
4
by: Rob | last post by:
This should be simple..... The default BackColor of a button (if you look at its property) is "Control" its a gray color, but apparently not a color. During a process I set the BackColor of a...
6
by: Dmitry Duginov | last post by:
Hi, I have the following label markup (label is inside FormView): <asp:Label ID="lblIndicatorReady" runat="server" Text="RE" ToolTip="Ready" BackColor='<%#...
11
by: tshad | last post by:
I have a Windows form where I am trying to set the BackColor of a control and check the color before I do it: If control.BackColor = System.Drawing.Color.Blue Then ChangeColor(control,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.