How to use comboBox

Post your questions regarding programming in C# in here.
4 posts Page 1 of 1
Contributors
User avatar
hortencio
New Member
New Member
Posts: 19
Joined: Thu Apr 19, 2012 1:41 am

How to use comboBox
hortencio
I would like to introduce some information in ComboBox in vb C# and when a select any information from the ComboBox such information has to be filled in the respective field.How can I do that?
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Re: How to use comboBox
comathi
Using code, you could add items to the ComboBox like so:
Code: Select all
ComboBox.Items.Add("ItemName")
Or, you could go to the ComboBox's properties and click on '...' next to the 'Items' property. This will bring up a window where gou can manually enter the items.

As for inputting the ComboBox data into a TextBox, for instance, you can use the following code:
Code: Select all
TextBox1.Text=ComboBox1.SelectedItem
This should work, but I'm on a mobile right now so I cannot double-check.

Anyways, hope this helps ;)
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: How to use comboBox
MrAksel
Its in the C# section ;)
Code: Select all
textBox1.Text = comboBox1.SelectedItem.ToString()
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Re: How to use comboBox
comathi
MrAksel wrote:
Its in the C# section ;)
Code: Select all
textBox1.Text = comboBox1.SelectedItem.ToString()
Oh, I see. Sorry about that. I got confused, as he named both languages in his post :lol:
hortencio wrote:
in vb C#
4 posts Page 1 of 1
Return to “General coding help”