473,396 Members | 2,018 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,396 software developers and data experts.

ComboBox - stopping it being "greyed" out when not enabled

If I have a combobox set enabled=false then by default it will have dark
grey text on a grey background. I want it to show as blue on white. I'm
trying code such as :

combobox.enabled=false
combobox.backcolor=color.white
combobox.forecolor=color.blue

This sets it to dark grey text on a white background.

How can I make the text blue?

Thanks in advance
Simon

Nov 21 '05 #1
2 15531
derive your own control from the combobox...
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
If I have a combobox set enabled=false then by default it will have dark
grey text on a grey background. I want it to show as blue on white. I'm
trying code such as :

combobox.enabled=false
combobox.backcolor=color.white
combobox.forecolor=color.blue

This sets it to dark grey text on a white background.

How can I make the text blue?

Thanks in advance
Simon

Nov 21 '05 #2
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
If I have a combobox set enabled=false then by default it will have dark
grey text on a grey background. I want it to show as blue on white. I'm
trying code such as :

combobox.enabled=false
combobox.backcolor=color.white
combobox.forecolor=color.blue

This sets it to dark grey text on a white background.

How can I make the text blue?


I needed to do something similar. We wanted the combo to look like a textbox
when locked, and all our text boxes were set to draw with a flat border when
read only. To do this I inherited from the standard combo as follows. Can't
guarantee that this will compile as is, as I've extracted it from a much
larger class, as we've modified a few other features of the combo box for
our own use.

Imports System.Windows.Forms
Public Class MyCombo
Inherits ComboBox

Private mReadOnly As Boolean

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Public Property ReadOnly() As Boolean
Get
Return mReadOnly
End Get
Set(ByVal Value As Boolean)
mReadOnly = Value
' Make the control non-editable
Me.Enabled = Not Value
' Tell the control to redraw itself when the user changes the locked
status
Me.Invalidate()
End Set
End Property

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
' When we get a redraw message, ans readonly has been set
If m.Msg = &HF And mReadOnly = True Then
Dim g As Graphics = Me.CreateGraphics
Dim p As New Pen(Color.Black, 1), b As Brush = New
SolidBrush(SystemColors.Control)
' Draw a flat black border
g.DrawRectangle(p, 0, 0, Width - 1, Height - 1)
' Fill it with a gray background
g.FillRectangle(b, 1, 1, Width - 2, Height - 2)
' Draw the combobox's displayed text inside it
g.DrawString(Me.Text, Me.Font, Brushes.Black, 3, 3)
End If
End Sub
End Class

Put this in your project and build the solution, then replace a combobox
with a mycombo, and set its readonly property to true.

Kev
Nov 21 '05 #3

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

Similar topics

5
by: Mały Piotruś | last post by:
Hello, (Sorry for my english.) I am new to HTML/JavaScript/CSS. I would like to ask for help with such a problem: I need to create a href link working like "back" button (I know this is not...
6
by: MLH | last post by:
You know how the text in the attached label sort of 'greys out' when you click something that sets MyTextbox.Enabled = False? I would like to make a label's text look like that? How do I do it?...
2
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
1
by: Phill. W | last post by:
I have a number of properties on a UserControl that are logically related to one another and do a specific job. What I'd /like/ to do is to have these properties available in the Forms Designer,...
2
by: Vark | last post by:
Interesting behavior I came across today where a child form has full access to a base form class' controls, but you can only modify the controls' properties in code, not in the visual designer....
6
by: =?Utf-8?B?S2Fp?= | last post by:
Hi all, using AJAX Toolkit with vb.net 2.0 how could I make this "Updating..." Screen like e.g. on Codeplex when you click on the "Vote" button...
4
by: Wayne | last post by:
I have an Office 2003 database with custom menu bars that work fine under Access 2007 with the following exception. The Officelinks menu item, "Analyze it with Microsoft Office Excel" is grey out...
6
by: =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post by:
I have an app that displays about 20 items of data in text boxes. Very occasionally I need to allow these to be used for data entry, but the bulk of the time they are solely for information. They...
0
by: Curious | last post by:
Hi, I try to set up debugging environment in Visual Studio 2003. So I open the Properties of the project and select "Debugging". I'll need to at first enter "C:\Program Files\AutoTrade\MyTools...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.