Skip to content

Displaying item in Combobox from checklistbox

trond 0

Asked Dec 13, 2004, 4:38 AM EST1 answer
Share
LinkedInX
I have a combobox that i populate with items from a checkedListBox. When the user is selecting an item in the checkedlistbox for the first time i want the combobox to show that item. As it is now it is just adding the selected item to the combobox: for (int y=0;y < checkedListBox1.CheckedItems.Count; y++) { cmbParameters.Items.Add(checkedListBox1.CheckedItems[y].ToString()); } Is there a way i can add some code so that the cmbParameters box is then set to that item as if the user selected it from the dropdown?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi, If U want to set the item when the user CHECKS the item in the checked listbox, then use this code . . . private void checkedListBox1_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e) { if ( e.NewValue == CheckState.Checked ) { cmbParameters.SelectedIndex = e.Index ; } } If U want to set the item when the user SELECTS the item in the checked listbox, then use this code . . . private void checkedListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { cmbParameters.SelectedIndex = checkedListBox1.SelectedIndex ; } Cheers, K a n n a . . .
    0