Results 1 to 6 of 6

Thread: comboBox

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2009
    Location
    West Sussex, England
    Posts
    62

    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

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    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

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3
    Lively Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    75

    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."

  4. #4
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: comboBox

    Quote Originally Posted by OldProgrammer View Post
    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

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  5. #5
    Lively Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    75

    Re: comboBox

    Are you scolding me?
    "The most important quality a programmer must have is persistence."

  6. #6
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: comboBox

    Quote Originally Posted by OldProgrammer View Post
    Are you scolding me?
    I'm not angry.

    You asked a question and I provided an answer.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote 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
  •  



Click Here to Expand Forum to Full Width