How to prevent enter data into a combobox control?

  • Thread starter Thread starter Li Pang
  • Start date Start date
L

Li Pang

I use a combobox control to populate the data. I want to
prevent to change data (freeze the data in the filed).
The only solution I have is to set Enabled property
to "False", but it gray out the field.

The question is how to change the color back to white?
Set the style property to "Dropdown List" is not an
optional. Is there is another way to fix it. There is a
solution in C++. But I need the codes in VB.Net

Thanks
 
Hi Li Pang,

You did post this before to this newsgroup I thought.

The text with the dropdownstyle =dropdownlist is

The user cannot directly edit the text portion.
The user must click the arrow button to display the list portion.

When I tried it, it did act like this.

I don't see your problem, what behaviour you want from the box?

(Or did you set it maybe to dropdown?)

Cor
 
* "Li Pang said:
I use a combobox control to populate the data. I want to
prevent to change data (freeze the data in the filed).
The only solution I have is to set Enabled property
to "False", but it gray out the field.

The question is how to change the color back to white?
Set the style property to "Dropdown List" is not an
optional. Is there is another way to fix it. There is a
solution in C++. But I need the codes in VB.Net

Change the system color settings.

SCNR
 
Hi Cor,

Think about textbox ReadOnly property. In the case of
ComboBox, I don't want users to CHANGE nor to EDIT the
text, ie the arrow button MUST be disabled, just like
disable the control.

DISABLED = false can resolve my problem, but it's hard to
read the text because the color is gray.

I posted this issue the second time, because most of
people can't understand me.

Thanks for your help.
 
i think i finally got you ;)

but i do have an extra question
why whould you need a combobox if you don't want your users to choose an
element? wouldn't a textbox be better for this?
alternative would be using dropdownstyle = dropdownlist as cor suggested and
make sure there is only 1 element in the list.

eric
 
Hi Li Pang,

In addition to Eric

Why not make 2 comboboxes (I was thinking about one combobox and one
textbox, but reading Erics text I think combinating both answer is the best
solution).

One is filled with 1 item and the other with all.
You put them on the same place
When needed you hide and show the one you want to use.

I think this fits totaly your problem.

Cor
 
Hi Cor and Eric,

Firstly, I'd like to thanks both you for your effort.
Secondly, I want let you know that I got the solution
already by meself as follows:
ComboBox1.BackColor = System.Drawing.Color.White
ComboBox1.Enabled = False
Thirdly, I explain your questions:
My stupid app uses a combobox to dosplaying data from a
listview. If user has permission then the data on the
combobox can be changed otherwise it is remained
in "Readonly" mode. Using a combobox is because it is
preloaded some values, ie. collection items are not empty.
So for the user has the permission, he/she can just change
the data within the collection items.

Sorry, I hadn't explained you the details.
 
Back
Top