|
-
Feb 8th, 2011, 06:22 AM
#1
Thread Starter
Addicted Member
how do i select items from combox?
i am using VS 2008.
and i am developing windows form application, i am a beginner for this.
i have a comboBox that contains colors, these are, Blue,Red,Green,Yellow and Pink.
I have populated them from the graphical interface in my visual studio project.
now i want to select one color so that i can assign it to my text box.
my comboBox name is comboBox1.
my textbox is TextBox1
if (combox1.selectedItem=="color")
then
textbox1.text="selected Color name"
so how can i assign it to my textbox1 by selecting from the dropdown list in my combobox1.
thanks for your hellping
Last edited by nebrom; Feb 8th, 2011 at 06:26 AM.
-
Feb 8th, 2011, 06:30 AM
#2
Re: how do i select items from combox?
In this case, you simply get the Text of the ComboBox and assign it to the Text of the TextBox. For those controls that it's logical, the Text property is where you get or set the text displayed in the control.
-
Feb 8th, 2011, 06:41 AM
#3
Thread Starter
Addicted Member
Re: how do i select items from combox?
thanks for you reply, but sorry i did not get you.
what i want is if i select Blue, then i will display it in textbox the name color Blue.
if i select green, then the value of the texbox1 one will be Green so can u code it.
so can u put somecodes thanks
-
Feb 8th, 2011, 07:07 AM
#4
Re: how do i select items from combox?
Rather than waiting for someone to write your code for you, read and think. You obviously already know how to set the Text property of a TextBox, because you've posted code that does it. It's not a stretch to get the Text property of a ComboBox, is it?
As for when to do it, handle the SelectedIndexChanged event of the ComboBox, which is raised each time the user changes the selection. If you can handle the Click event of a Button then you can handle the SelectedIndexChanged event of a ComboBox.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|