473,587 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changeing fore color of disabled combo box

our form, when it is in read only mode has about 10 combo boxes on it, and a
bunch of text boxes, now the text box has a read only property which makes
the text black, but the combo box doesn't so we have to disable it to make
it "readonly" but the text is gray on gray... which is hard to read for some
people. Is there any way to make the combo boxes forecolor black to match
the textbox's forecolor when its read only? thanks
Nov 20 '05 #1
3 7155
Brian,
I don't think there is any color that will not appear grayed. If it were a
TextBox, you could make it readonly, but the combo does not have such a
property. Set the font to Bold makes it more readable and if you don't want
it bold when enabled, un bold it.

That's the best I can think of.
HTH
Les Smith
http://www.KnowDotNet.com

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:O8******** *****@TK2MSFTNG P09.phx.gbl...
our form, when it is in read only mode has about 10 combo boxes on it, and a bunch of text boxes, now the text box has a read only property which makes
the text black, but the combo box doesn't so we have to disable it to make
it "readonly" but the text is gray on gray... which is hard to read for some people. Is there any way to make the combo boxes forecolor black to match
the textbox's forecolor when its read only? thanks

Nov 20 '05 #2
Brian,
Create you own control inherited from ComboBox

<ToolboxBitmap( GetType(System. Windows.Forms.C omboBox))> _
Public Class ReadOnlyComboBo x
Inherits System.Windows. Forms.ComboBox

Private m_ReadOnly As Boolean = False
Public Event ReadOnlyChanged As EventHandler

<Category("Beha vior"), DefaultValue(Fa lse), Bindable(True), _
Description("Co ntrols whether text in the control can be changed")> _
Public Property [ReadOnly]() As Boolean
'Gets of sets the ReadOnly flag
Get
Return m_ReadOnly
End Get
Set(ByVal Value As Boolean)
'Check if the color was changed
If m_ReadOnly <> Value Then
m_ReadOnly = Value
OnReadOnlyChang ed()
End If
End Set
End Property

Protected Overridable Sub OnReadOnlyChang ed()
MyBase.TabStop = Not m_ReadOnly
'Raise event
RaiseEvent ReadOnlyChanged (Me, New EventArgs())
End Sub

Public Overrides Function PreProcessMessa ge(ByRef msg As Message) As Boolean
'Prevent keyboard entry if control is ReadOnly
If m_ReadOnly = True Then
'Check if its a keydown message
If msg.Msg = &H100 Then
'Get the key that was pressed
Dim key As Int32 = msg.WParam.ToIn t32
'Ignore navigation keys
If key = Keys.Tab Or key = Keys.Left Or key = Keys.Right Then
'Do nothing
Else
Return True
End If
End If
End If
'Call base method so delegates receive event
Return MyBase.PreProce ssMessage(msg)
End Function

Protected Overrides Sub WndProc(ByRef m As Message)
'Prevent list displaying if ReadOnly
If m_ReadOnly = True Then
If m.Msg = &H201 OrElse m.Msg = &H203 Then
Return
End If
End If
'Call base method so delegates receive event
MyBase.WndProc( m)
End Sub

Stephen
"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:O8******** *****@TK2MSFTNG P09.phx.gbl...
our form, when it is in read only mode has about 10 combo boxes on it, and a bunch of text boxes, now the text box has a read only property which makes
the text black, but the combo box doesn't so we have to disable it to make
it "readonly" but the text is gray on gray... which is hard to read for some people. Is there any way to make the combo boxes forecolor black to match
the textbox's forecolor when its read only? thanks

Nov 20 '05 #3
thanks

"Stephen Muecke" <st*****@senet. com.au> wrote in message
news:Of******** ******@TK2MSFTN GP09.phx.gbl...
Brian,
Create you own control inherited from ComboBox

<ToolboxBitmap( GetType(System. Windows.Forms.C omboBox))> _
Public Class ReadOnlyComboBo x
Inherits System.Windows. Forms.ComboBox

Private m_ReadOnly As Boolean = False
Public Event ReadOnlyChanged As EventHandler

<Category("Beha vior"), DefaultValue(Fa lse), Bindable(True), _
Description("Co ntrols whether text in the control can be changed")> _
Public Property [ReadOnly]() As Boolean
'Gets of sets the ReadOnly flag
Get
Return m_ReadOnly
End Get
Set(ByVal Value As Boolean)
'Check if the color was changed
If m_ReadOnly <> Value Then
m_ReadOnly = Value
OnReadOnlyChang ed()
End If
End Set
End Property

Protected Overridable Sub OnReadOnlyChang ed()
MyBase.TabStop = Not m_ReadOnly
'Raise event
RaiseEvent ReadOnlyChanged (Me, New EventArgs())
End Sub

Public Overrides Function PreProcessMessa ge(ByRef msg As Message) As Boolean 'Prevent keyboard entry if control is ReadOnly
If m_ReadOnly = True Then
'Check if its a keydown message
If msg.Msg = &H100 Then
'Get the key that was pressed
Dim key As Int32 = msg.WParam.ToIn t32
'Ignore navigation keys
If key = Keys.Tab Or key = Keys.Left Or key = Keys.Right Then
'Do nothing
Else
Return True
End If
End If
End If
'Call base method so delegates receive event
Return MyBase.PreProce ssMessage(msg)
End Function

Protected Overrides Sub WndProc(ByRef m As Message)
'Prevent list displaying if ReadOnly
If m_ReadOnly = True Then
If m.Msg = &H201 OrElse m.Msg = &H203 Then
Return
End If
End If
'Call base method so delegates receive event
MyBase.WndProc( m)
End Sub

Stephen
"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:O8******** *****@TK2MSFTNG P09.phx.gbl...
our form, when it is in read only mode has about 10 combo boxes on it, and
a
bunch of text boxes, now the text box has a read only property which

makes the text black, but the combo box doesn't so we have to disable it to make it "readonly" but the text is gray on gray... which is hard to read for

some
people. Is there any way to make the combo boxes forecolor black to match the textbox's forecolor when its read only? thanks


Nov 20 '05 #4

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

Similar topics

1
5058
by: Antonio | last post by:
Good Morning, for my application I need to set the disabled color of the checkboxes to blue, how can I do this ??? I know for the combo there is UIManager.put("ComboBox.disabledForeground", new Color(0,0,255)); but seems there is nothing of similar for the checkbox, maybe SUN doesn't think to this ??? Can you help me to ha ve a blue...
0
1201
by: Gabriele Farina | last post by:
Hi guys, I have to implement a wizard that works like the Mozilla Firefox preferences screen (I need some buttons on the left and I have to change right content based on the button pressed). How can I manage this? I have to create N panels that contains my widgets and then displaing them based on the button pressed? I tried somethig like that,...
2
1670
by: Rahul | last post by:
is it possible to set texts with different fore- background colors in textbox control? Any pointers appreciated! Rahul
1
1557
by: Sally Chamness | last post by:
Hello everyone, Im working on a final VB.Net project which im building in Visual Studio 2005. In my application, I have a combo box with lists 10 items, when an item from the combo box is selected an image of the item appears, as well as 3 ingredients of said item. I also have a text box so that the user can enter in the number of items they...
2
2190
by: Melisa | last post by:
Hi, 1. I want to change the alpha value of fore color of a button at run time to fade it. 2. I have a button and some text is assigned to it`s Text property. 3. I want to fade the color of this text OnMouseMove event. 4. When i change the alpha value of back color of the button, it shows same behaviour on MouseMove event but when i change...
0
1647
by: uthooker | last post by:
I have an Access form with some combo boxes in the Form Header that are enabled/disabled using conditional formatting based on the setting in a checkbox also in the Header (Combo box = Enabled by default; when Checkbox = False, Combo Box = Disabled.). When I open the form, the combo boxes are behaving as expected, and when I change records...
3
1208
by: Karthiga1984 | last post by:
is it possible to change some rows fore color??? for example the particular column number is greater than 0 that records would be appear in red color(forecolor is red) ..remaining recods would be appear in blue color. all records is in same combo box... is it possible.??? please do help..
0
1148
by: Plack | last post by:
Hello, as I had the same problem as many others with the fixed back and fore color of disabled controls I decided to implement my own controls where exactly this behaviour is provided. I know that it is not "the optimal solution", but it works and I wanted to share it with everybody who is interested in. For more details see the following...
2
8433
by: MicaK | last post by:
Good Morning, I am new to this forum, and extremely new to VBA, so there may be a very simple explanation to this. I also apologize if I am giving you and excessive amount of detail. I have a table, tblAdmissions. One of the columns is for Certification and was set up as a lookup field that allows multiple values to be selected. In my form,...
0
7920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.