Home Forums WinForms controls Other WinForms controls Set value in Wincombobox

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18535 |

    Hello!

    I’ve a wincombobox with 2 columns: cPlazos & cValores

    I set the ValueMember to cPlazos and I need to set the value of cValores from a textbox for the wincombobox’ SelectedItem

    How can I do it?

     Thank you! 🙂

    Imported from legacy forums. Posted by kknuke (had 2175 views)

    User (Old forums)
    Member
    Post count: 23064

    You will need to identify the item that contains the text from the TextBox, and set the item as the SelectedItem.

    e.g.:

          foreach( ComboBoxItem item in winComboBox1.Items )
          {
            if( item.Values.Contains( textBox1.Text ) )
            {
              winComboBox1.SelectedItem = item;
              break;
            }
          }
     

     

    Imported from legacy forums. Posted by André (had 2579 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.