none
DataGridview Multi selection Combo box RRS feed

  • Question

  • In datagridview  i have two columns first Column contains Form name And second Column is Combo box Which contains User Name ,

    I have to set permission by selecting multi users .

    My question is how can i select multi Users in Datagridview Combo box .

    If there is any other way to do this then please help me it's urgent . 

     
    Thursday, October 25, 2012 1:15 PM

Answers

  • ComboBox IS only meant to select a single item - by default. If you want to select multiple items, then you will have to create your own comboBox, derived from the original one. 

    Maybe there is some simple work around, but I would use it. I will tell you anyway. Create a list, clear it before 1st selection of particulat comboBox, then on each selection the item will be added to this list (but let the user now this is possible/available, you can even show selection on some place if you like). But thats it - you cannot do much more then that!


    Mitja

    Thursday, October 25, 2012 4:02 PM
  • Hi Sanjay,

    ComboBox is designed for users to select an item or input a value as Mitja said. You need to create a custom control if you want to select multiple items in ComboBox. For example:

    http://www.codeproject.com/Articles/18929/An-OwnerDraw-ComboBox-with-CheckBoxes-in-the-Drop

    To host controls in datagridview cells, you have to customize your datagridviewcolumn, datagridviewcell and editing controls.

    http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, October 30, 2012 9:00 AM
    Moderator
  • You could take a different approach by using a master detail view such as shown below which you would have different fields/columns but similar. The example below obtains data from a database with three tables, form, user, security. If you are not using a database a xml file structure would also work or any data source which you can set up relations.


    KSG

    Tuesday, October 30, 2012 6:33 PM
    Moderator

All replies

  • ComboBox IS only meant to select a single item - by default. If you want to select multiple items, then you will have to create your own comboBox, derived from the original one. 

    Maybe there is some simple work around, but I would use it. I will tell you anyway. Create a list, clear it before 1st selection of particulat comboBox, then on each selection the item will be added to this list (but let the user now this is possible/available, you can even show selection on some place if you like). But thats it - you cannot do much more then that!


    Mitja

    Thursday, October 25, 2012 4:02 PM
  • Thanks Mitja Bonca

    but i am still waiting for good answer .
    Friday, October 26, 2012 2:36 AM
  • Hi Sanjay,

    ComboBox is designed for users to select an item or input a value as Mitja said. You need to create a custom control if you want to select multiple items in ComboBox. For example:

    http://www.codeproject.com/Articles/18929/An-OwnerDraw-ComboBox-with-CheckBoxes-in-the-Drop

    To host controls in datagridview cells, you have to customize your datagridviewcolumn, datagridviewcell and editing controls.

    http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, October 30, 2012 9:00 AM
    Moderator
  • You could take a different approach by using a master detail view such as shown below which you would have different fields/columns but similar. The example below obtains data from a database with three tables, form, user, security. If you are not using a database a xml file structure would also work or any data source which you can set up relations.


    KSG

    Tuesday, October 30, 2012 6:33 PM
    Moderator