Posted 22 October 2018, 3:43 pm EST
Hi Don,
You can use a ComboBox as Editor of a column and set the table as DataSource of the ComboBox. Also, if you have a table with key-value pairs (for eg. EmployeeID, EmployeeName) and you want to display the value (EmployeeName), you would need to use DataMap property of the column so that initial values of the grid are also mapped correctly.
Here’s an example of a simple ComboBox editor:
Dim comboEmployee = New ComboBox()
comboEmployee.DataSource = GetDataTable("select EmployeeID from Employees")
comboEmployee.DisplayMember = "EmployeeID"
C1FlexGrid1.Cols("EmployeeID").Editor = comboEmployee
For a ComboBox with mapped values, you can do something like this:
Dim comboCustomer = New ComboBox()
Dim customerTable = GetDataTable("select CustomerID, CompanyName from Customers")
comboCustomer.DataSource = customerTable
comboCustomer.DisplayMember = "CompanyName"
comboCustomer.ValueMember = "CompanyName"
C1FlexGrid1.Cols("CustomerID").Editor = comboCustomer
Dim dictionary = New Dictionary(Of String, String)()
For row = 0 To customerTable.Rows.Count - 1
dictionary.Add(customerTable(row)("CustomerID"), customerTable(row)("CompanyName"))
Next
C1FlexGrid1.Cols("CustomerID").DataMap = dictionary
Please refer to the attached sample to see an example of both methods.
Regards,
Jitender
DynamicDropdown.zip