471,083 Members | 1,066 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,083 software developers and data experts.

Set the default "initial" value of a ComboBox

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?
Nov 20 '05 #1
2 39998
* "=?Utf-8?B?S2VpdGg=?=" <an*******@discussions.microsoft.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
You want "SelectedItem," not "Text."

--George

"Keith" <an*******@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
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.
Why is that?

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

46 posts views Thread by TTroy | last post: by
8 posts views Thread by Peter Merwood | last post: by
7 posts views Thread by Carsten H. Pedersen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.