how to: Combobox uneditable yet Text remain Black??
Hello community...
I wish to make a combo box uneditable untill an event. The combo box is bound to a datasource so data is visible within the box at its creation. I want this data do be black instead of the greyed out default in an uneditable combo box.
I have tried the following
VB Code:
cboGeneric.enabled = false
cboGeneric.foreColor= color.black
and this fails.. i have also trid severla other tricks and they have failed also.. any sugestions are appreciated...
Re: how to: Combobox uneditable yet Text remain Black??
Lol Stimbo..i meant still Grey!...not black..sorry about that..
As for the rest , thank you.. i figure ill just overlay the control witha text box and hide the one i dont need upon an event... and just make the text box read only...
Re: how to: Combobox uneditable yet Text remain Black??
Now it all makes sense.
Umm, never done this before but there are loads of examples where you create your own control (combobox in this case) for example that inherits fromt the VB combobox but that is also read only (you add extra properties). That may work but someone more experienced should post to confirm that it's not a massive task and simple to achieve....
(people have posted examples with a textbox only accepting numeric input for example.)
Re: how to: Combobox uneditable yet Text remain Black??
when setting a control's enabled property to false, the default behavior is to gray out the control (as you know)
This is a standard thing in windows, and if you were to change it to make it black instead of gray, then it would just confuse the end users, and they would likely think something is wrong with the program.
If you came across a control that looked like it was enabled, but it wasn't, wouldn't that confuse you? Unless you have some specific reason, I would leave it as it is, and let it look disabled, because it is disabled.
Re: how to: Combobox uneditable yet Text remain Black??
The reason for the odd request is as follows...
Users view a combo box with information they are unable to change at time of viewing. Upon a certain update request event... the combo box would swich from enabled=false to enabled=true.
The issue arose because the text was faint in the unenabled box, some users could not read it clearly to confirm the contents, thus my intention was to simply make the text more visible to the users.
I fully understand the reason for leaving greyed out as explained and will just have to programaticaly create a work around for those users who insists otherwise.
THank you all.. for your help.. i learn something new every time i come here...
Re: how to: Combobox uneditable yet Text remain Black??
Another possible solution could be achived using 2 comboboxes. One is "DropDownList" and another is normal "DropDown".
Load the data in both comboboxes.
Place them in same location on the form.
In 'ReadOnly' mode show the "DropDownList".
In 'EditMode' show the "DropDown" box.
(I don't know if there is a way to change the style during runtme in VB.NET)
Re: how to: Combobox uneditable yet Text remain Black??
I got a bit interested, so I made a custom class that inherits from Combobox, but has an option to simply disallow the user to change the selection. It won't look disabled, it just won't allow them to drop down the combo, or use the keyboard to change the selection until you change the AllowToDropDown property to true (which can be done at design time or runtime)
this should give you what you want, and maybe teach you a thing or 2 about extending the standard controls to fit your needs, without workarounds like adding extra controls and doing visible swaps with them.
The code is commented so you can see whats going on.
Since I don't upload the compiled files, when you open the project, you need to build the project first, then you can view form1.