I am binding a radgridview to a datatable the datatable contains a field ‘TankLevel’ that can have one of 5 values ‘1/4’, ‘half’, ¾’ , ‘Full’ or ‘Unknown’ I want to display this column as a GridViewComboBoxColumn and display the value from the underlying datatable and have each of the 5 values available in the comboboxcolumn dropdown. When I bind to the datatable the combobox is populated with the data but combobox in each row has every row available in the dropdown! How can I make each row show the underlying record but irestrict the dropdown to the 5 values n order that the user can select from the other 4 values.
Dim cboCol As GridViewComboBoxColumn = New GridViewComboBoxColumn
cboCol.Name = "cboCol"
cboCol.HeaderText = "Fill Level"
cboCol.DataSource = sVehDT
cboCol.ValueMember = "TankLevel"
cboCol.DisplayMember = "TankLevel"
cboCol.FieldName = "TankLevel"
6 Answers, 1 is accepted
The code would look something like this:
Thanks for your reply to my post. I have implemented your suggestion and am now adding the columns at runtime all columns are populated with the data from the dtatatable apart from the "TankLevel' combobox which is blank but has the values available in the dropdown.
I'm a little confused by your reply. Is your problem solved? If so, please mark my reply as the solution. If not, please elaborate on the issue.
Found the issue, I changed the bound items to an indexed list and the combobox behaved as I wanted it to. Thanks for your help with this issue.
You can insert the column or move it after it is added to the grid:
I hope this will be useful. Let me know if you have additional questions.