|
-
Jan 12th, 2010, 03:04 PM
#1
Thread Starter
Member
comboBox
Hi,
I have created a comboBox and want to set it so when a user selects option1 from the drop down list. a Text box populates with text for the user to see.
Is this possible?
Thanks
-
Jan 12th, 2010, 03:15 PM
#2
Re: comboBox
Each item in the combobox is assigned an index starting at 0. From there, you can test which item is selected with a conditional logic statement (If...Then...). If the item selected is at your index (0), then call the TextBox's Text property and assign it the SelectedItem.
Since the items in a ComboBox are object, you to to convert them .ToString.
Make sure you're doing all of this in the default event, which can be created by double-clicking on the ComboBox in the designer.
Last edited by weirddemon; Jan 12th, 2010 at 03:21 PM.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Jan 12th, 2010, 04:51 PM
#3
Lively Member
Re: comboBox
Why not just do the following:
HTML Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ComboBox1.Text
End Sub
"The most important quality a programmer must have is persistence."
-
Jan 12th, 2010, 04:52 PM
#4
Re: comboBox
 Originally Posted by OldProgrammer
Why not just do the following:
HTML Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ComboBox1.Text
End Sub
1. That gives him an answer instead of allowing him to to figure it out on his own.
2. He may need to know if a specific item is selected. What if he wants the text to appear in the box if the first item is elected, but additional options appear on the second? And so on.
3. And the OP asked how he could accomplish his task when the first item was selected, not any.
Last edited by weirddemon; Jan 12th, 2010 at 04:57 PM.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Jan 12th, 2010, 10:58 PM
#5
Lively Member
"The most important quality a programmer must have is persistence."
-
Jan 12th, 2010, 11:16 PM
#6
Re: comboBox
 Originally Posted by OldProgrammer
Are you scolding me?
I'm not angry.
You asked a question and I provided an answer.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
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
|