CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Combo Box

  1. #1
    Join Date
    Oct 2002
    Posts
    34

    Combo Box

    Hi!

    I would like to update the selected item of a combo box after a bunch of algo have been performed.

    I used this:
    ' I first clear it
    myComboBox.text = " "
    ' Then I set it later on in my code using the following
    myComboBox.selecteditem = index

    My problem is that sometimes it shows the right value, sometimes it stays blank.

    Help!

    Thank you
    Have a nice day! (^_^)

  2. #2
    Join Date
    May 2002
    Location
    Toronto
    Posts
    167
    any reason you don't want to use

    mycomboBox.Items.Add(textBox1.Text)
    mycomboBox.Items.Add(textBox2.Text)

    ....

  3. #3
    Join Date
    Oct 2002
    Posts
    34
    Well the item exist. Just that I am having problem setting it into view.
    Have a nice day! (^_^)

  4. #4
    Join Date
    May 2002
    Location
    Toronto
    Posts
    167
    ok maybe I read your question wrong, sorry the list exists already and you just want to change the Drop down box text so it shows the value of "index" in the top part ?

    or are you using index as a value like index = 2 therefore you want the second one to be the selecteditem ?

  5. #5
    Join Date
    Oct 2002
    Posts
    34
    I got it set to 2. Then I clear it. After that, I want to set it to 3. I tried doing it seperately from my program and it works. I think that it might be that something overwrote it before it showed on the interface.

    Thank you for your help.
    Have a nice day! (^_^)

  6. #6
    Join Date
    May 2002
    Location
    Toronto
    Posts
    167
    2 suggestions

    1) mycombobox.selectedindex = 3

    2) mycombobox.text = "whatever item 3 is" 'when in doubt cheat :-)

  7. #7
    Join Date
    Oct 2002
    Posts
    34
    That's what I did in the end. I cheated :P
    Plz don't tell anyone
    Have a nice day! (^_^)

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

Featured