سؤال

I have a checkedlistbox in C# language, that I want to have multiselection,

but the problem is when I type checkedlistbox.SelectedItems , it only contains properties of last selected item.

Whats the solution ?

هل كانت مفيدة؟

المحلول

You need to set SelectionMode of your checkedlistbox to MultiSimple or MultiExtended to enable multiple selection.

Various modes -

  • One - Only one item can be selected.
  • None - No items can be selected.
  • MultiSimple - Multiple items can be selected.
  • MultiExtended - Multiple items can be selected, and the user can use the SHIFT, CTRL, and arrow keys to make selections

EDIT

You can't set multiple selection for checkedListBox as per MSDN -

The SelectionMode property determines whether one item in the list box can be selected or no items can be selected. For CheckedListBox objects, multiple selection is not supported. You can set the mode to one item or no items.

Even I tried setting it and as stated it throws ArgumentException at runtime -

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top