FlexGrid (VB.NET) How To Add a databound dropdown list in code

Posted by: mwebster on 25 November 2020, 3:41 pm EST

    • Post Options:
    • Link

    Posted 25 November 2020, 3:41 pm EST

    Hello,

    I am working in VB.NET and I am using the FlexGrid control. I need to add a column with a databound dropdown list. It needs to have a value (integer) and a display value (string) which it will get from the database. The user needs to be able to select a value when adding/editing a row and of course, the control needs to display the correct display value (depending on the value of the field) when rows are loaded. I can’t seem to find any instructions on how to accomplish this.

    Thanks,

    Mike

  • Posted 25 November 2020, 3:56 pm EST

    I tried this which sort of works:

        Dim ComboSegment As New ComboBox
        ComboSegment.DataSource = SegmentTable
        ComboSegment.DisplayMember = "Name"
        ComboSegment.ValueMember = "SegmentID"
        Dim col3 As C1.Win.C1FlexGrid.Column
        col3 = C1FlexGrid1.Cols.Add()
        col3.Name = "SegmentID"
        col3.Caption = "Segment"
        col3.Editor = ComboSegment
    

    The problem is that the FlexGrid column displays the key value (valuemember) unless the cell is in edit more at which time it displays the displaymember of the combo box. That of course does not work very well for users.

  • Posted 25 November 2020, 4:21 pm EST

    Figured out how to do it with a DataMap. Is that the best way to do this?

  • Posted 26 November 2020, 4:40 am EST

    Hi,

    Yes, the best way to do this will be to use a DataMap, please refer to the sample attached.

    For more details on using DataMap, refer to this link:

    https://www.grapecity.com/componentone/docs/win/online-flexgrid/valuemappedlists.html?highlight=datamap%2C

    If you have any other questions, please let me know.

    Regards,

    Prabhat Sharma.

    FGDataMap.zip

Need extra support?

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

Learn More

Forum Channels