How to add a combobox in a gridview column

Posted by: nithya.naomi on 11 June 2018, 1:13 pm EST

    • Post Options:
    • Link

    Posted 11 June 2018, 1:13 pm EST

    Hi I am trying to make a column in the flexgrid as a dropdow. I need to load this at runtime. I am trying to use the below code but the combolist property takes only a string and not a key value object

     Dim _defaultCol As C1.Win.C1FlexGrid.Column
            _defaultCol = grdLinkSuppliers.Cols.Add()
            _defaultCol.Name = "Default BU"
            _defaultCol.Caption = "Dafault BU"
            _defaultCol.ComboList = "UK|USA|Dubai|Asia"
            _defaultCol.Width = 55
    

    The values in my combo list actually come from the database. The have an Id and a code. I need the column to function as a regular combobox so I can save the selected item in the combo as Id and show the same on retrieving the data.

  • Posted 12 June 2018, 4:20 am EST

    Hi,

    you can use the “_defaultCol.DataMap” property instead of “ComboList”. Here, the column contains a key (e.g. an ID from the database), and those keys are mapped to display values through the datamap.

    Take a look at the sample “CustomDataMap”: https://www.grapecity.com/en/samples/customdatamap

    The datamap can be a hashtable, but also e.g. a “SortedDictionary”.

    Hope this helps

    Wolfgang

  • Posted 13 June 2018, 5:08 am EST

    Thanks for solution Wolfgang!

  • Posted 13 June 2018, 5:10 am EST

    Hello Nithya,

    You can use the Wolfgang solution. Additionally, to achieve your requirement, you can use ComboBox control as editor of the column of the C1FlexGrid. Please refer the attached ample to achieve the same.

    Thanks,

    Mohit

    ComboBoxItemsUsingDB (1).zip

  • Posted 25 June 2018, 4:45 am EST

    Thank you ! This was very helpful.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels