Click to See Complete Forum and Search --> : ComboBox Text Property


Radu
October 22nd, 2001, 04:32 AM
Hi,

I am having a ComboBox called targetCombo. The first item which shows up is set with

targetCombo.text = "jhg"

The problem is that when I want to change it I get the Error that the Text Property is read only.
How can I change the first choice in the combo box?

One more question:

Depending on a selection in the combo box I want a radio button to enable or disable. How can I make the comboBox selection take action on the radio button?

JHamilton
October 22nd, 2001, 04:43 AM
you have to select the item thru the List property.


combo1.list(1) = "Blah"




Software is like sex, it's better when it's free - Linus Torvalds
Software is like sex, it's better when I get paid for it. - me

Boumxyz2
October 22nd, 2001, 08:00 AM
You can use combobox.value = "Your text here"

John G Duffy
October 22nd, 2001, 10:43 AM
If your ComboBox style property is set to DropDropDown List (2) then it is indeed a Readonly box. Set the style to 0 or 1 to be able to enter data into it programattically. To prevent users from keying data when style is 0 or 1, add this to the KeyPress event of the comboBox

private Sub Combo1_KeyPress(KeyAscii as Integer)
KeyAscii = 0
End Sub




John G

DSJ
October 22nd, 2001, 01:19 PM
option Explicit

private Sub Combo1_Change()
If Combo1.Text = "Item1 - RadioButton Enabled" then
Option1.Enabled = true
else
Option1.Enabled = false
End If
End Sub

private Sub Combo1_Click()
Combo1_Change
End Sub

private Sub Form_Load()
Combo1.AddItem "Item1 - RadioButton Enabled"
Combo1.AddItem "Item2 - RadioButton Disabled"

Combo1.Text = "Item1 - RadioButton Enabled"
End Sub