473,320 Members | 1,953 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,320 software developers and data experts.

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 7140
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**********@newsgroups.nospam> wrote in message
news:O8*************@TK2MSFTNGP09.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.ComboB ox))> _
Public Class ReadOnlyComboBox
Inherits System.Windows.Forms.ComboBox

Private m_ReadOnly As Boolean = False
Public Event ReadOnlyChanged As EventHandler

<Category("Behavior"), DefaultValue(False), Bindable(True), _
Description("Controls 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
OnReadOnlyChanged()
End If
End Set
End Property

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

Public Overrides Function PreProcessMessage(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.ToInt32
'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.PreProcessMessage(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**********@newsgroups.nospam> wrote in message
news:O8*************@TK2MSFTNGP09.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**************@TK2MSFTNGP09.phx.gbl...
Brian,
Create you own control inherited from ComboBox

<ToolboxBitmap(GetType(System.Windows.Forms.ComboB ox))> _
Public Class ReadOnlyComboBox
Inherits System.Windows.Forms.ComboBox

Private m_ReadOnly As Boolean = False
Public Event ReadOnlyChanged As EventHandler

<Category("Behavior"), DefaultValue(False), Bindable(True), _
Description("Controls 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
OnReadOnlyChanged()
End If
End Set
End Property

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

Public Overrides Function PreProcessMessage(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.ToInt32
'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.PreProcessMessage(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**********@newsgroups.nospam> wrote in message
news:O8*************@TK2MSFTNGP09.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
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",...
0
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...
2
by: Rahul | last post by:
is it possible to set texts with different fore- background colors in textbox control? Any pointers appreciated! Rahul
1
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...
2
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...
0
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...
3
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...
0
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...
2
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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...
1
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...
1
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....
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.