PDA

Click to See Complete Forum and Search --> : Combobox properties got me confused


scottr
Aug 5th, 1999, 08:04 PM
Hi all,

I have combo boxes which are populated with dynamic sql from sql 7.0. I want to have the combo box style as read only so that the user cant write in a value that is not present. The problem is that I have a grid, when the user click the grid it will populate the text part of the combo box with the users choice then go out to sql and retrieve the values for the combo box. I am unable to populate the text portion because it is read only. I guess after all this typing is how can i make the combo box read the grid but be locked if anything is typed inside of it.

thanks

Scott

preeti
Aug 5th, 1999, 09:13 PM
Hi,

Try unlocking it before you write from the grid, then relock right after.

combobox.locked=false
combobox.text=gridvalue
combobox.locked=true

Hope this helps,

Preeti

scottr
Aug 5th, 1999, 10:41 PM
If you lock it then the combo is locked-it cant be changed at all, the dropdown wont work.

preeti
Aug 6th, 1999, 12:06 AM
Hi,

Okay, now I see what you are trying to do.

Why don't you add the item to your combobox, then select that item through code:

Combobox.AddItem gridvalue
Combobox.ListIndex = Combobox.ListCount - 1

the second line will place in the text part of the combobox the last item that was entered into the combobox.

Hope this helps,

Preeti

scottr
Aug 6th, 1999, 01:00 AM
That works the only problem is that when i populate the combobox from the server and get items
1
2
3

if i add the item lets say 1
then my combobox looks like this
1
2
3
1

if i try to delete it afterwords then the textbox portion becomes blank.

preeti
Aug 6th, 1999, 11:11 AM
How are you making the combo boxes read only now?

Whatever property you are setting, at
run-time, reset the property to read and write, then write in the value from the grid, then reset your combo box back to read-only.

Or is your question how to make a combo box read only?

Preeti

scottr
Aug 6th, 1999, 11:42 AM
at first i set the property in the settings, but then i wanted to do in code.
u can choose dropdown combo
simple combo or dropdown list

but i decided to try the code

combobox.style=2

only problem if i try to change it from read to write, i get warning messages.

basically i just want the user to only be able to choose values from the combo box, not write their own in.