Set the default "initial" value of a ComboBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have populated (or created a collection) in a ComboBox. However - I would like to set a default value - when my form is first opened (for the ComboBox) - like "Select topic"

However - when I attempt to add this text to the Text property of the Combobox - it does not take. In other words, I type it in the property - but when I leave the field - it is blank. I also tried modifying the ComboBox control - in the following manner

'ComboBox

Me.ComboBox1.Items.Add("1"
Me.ComboBox1.Items.Add("2"
Me.ComboBox1.Items.Add("3"
Me.ComboBox1.Items.Add("4"
Me.ComboBox1.Location = New System.Drawing.Point(56, 38
Me.ComboBox1.Size = New System.Drawing.Size(176, 22
Me.ComboBox1.Text = "Select Topic

I added the last line "Me.ComboBox1.Text = "Select Topic" - but again - it would not apply the value - when I sent to the emulator.

Why is that?
 
* "=?Utf-8?B?S2VpdGg=?= said:
I have populated (or created a collection) in a ComboBox. However - I would like to set a default value - when my form is first opened (for the ComboBox) - like "Select topic".

Set the control's 'SelectedIndex' property.
 
You want "SelectedItem," not "Text."

--George

Keith said:
I have populated (or created a collection) in a ComboBox. However - I
would like to set a default value - when my form is first opened (for the
ComboBox) - like "Select topic".
However - when I attempt to add this text to the Text property of the
Combobox - it does not take. In other words, I type it in the property -
but when I leave the field - it is blank. I also tried modifying the
ComboBox control - in the following manner:
'ComboBox1
'
Me.ComboBox1.Items.Add("1")
Me.ComboBox1.Items.Add("2")
Me.ComboBox1.Items.Add("3")
Me.ComboBox1.Items.Add("4")
Me.ComboBox1.Location = New System.Drawing.Point(56, 38)
Me.ComboBox1.Size = New System.Drawing.Size(176, 22)
Me.ComboBox1.Text = "Select Topic"

I added the last line "Me.ComboBox1.Text = "Select Topic" - but again - it
would not apply the value - when I sent to the emulator.
 
Back
Top