locked
MultiSelect ListBox in DataGridView RRS feed

  • Question

  • Hi

    I need code to display MultiSelect ListBox in one of the clomuns in a DataGridView. The ListBox should be miltiselect with checkboxes.

    thanks


    Annant
    • Moved by Figo Fei Thursday, July 1, 2010 5:50 AM (From:Visual C# General)
    Wednesday, June 30, 2010 11:13 AM

Answers

  • Hi Annant,

    Based on your requirement, it is better to use CheckedListBox instead of ListBox, which supports muti-selection with CheckBoxes. You could follow the similar way shown in the document below to wrap this control and create a new DataGridViewColumn:
    http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

    Regards,
    Aland Li

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    • Marked as answer by Aland Li Wednesday, July 7, 2010 1:54 PM
    Friday, July 2, 2010 3:19 AM

All replies

  • Hello,

    You can add an combobox by following code:

      DataGridViewComboBoxColumn comboboxcol = new DataGridViewComboBoxColumn();
          dataGridView1.Columns.Add(comboboxcol);

    I am trying furthur to display the checkbox within the combobox.

    Is this what you want?

    Regards,

    Wednesday, June 30, 2010 12:35 PM
  • Hello Annant,

     

    This requirement is for WPF or Win Forms?

    If it is in Winforms then I think you need to review your requirement itself. Bcoz logically how can an gridview have a listbox with multiselect?

    Can you please get back with your requirement in detail .

    I am sorry if I have interpreted your requirement in an wrong way.

    Regards,

    Thursday, July 1, 2010 5:58 AM
  • Hi Annant,

    Based on your requirement, it is better to use CheckedListBox instead of ListBox, which supports muti-selection with CheckBoxes. You could follow the similar way shown in the document below to wrap this control and create a new DataGridViewColumn:
    http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

    Regards,
    Aland Li

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    • Marked as answer by Aland Li Wednesday, July 7, 2010 1:54 PM
    Friday, July 2, 2010 3:19 AM
  • Hi Annant,

    How is your issue now? Does my reply helps?

    Regards,
    Aland Li

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    Monday, July 5, 2010 2:53 AM