[Refer attached for sample project]
Question: How to add Combo Box in a RadGridView Cell?
Requirements:
- The column is a GridViewTextBoxColumn, not GridViewComboBoxColumn.
- Depending on the column type, the column will be populated dynamically with either Combo Box or Text Field.
- Each combo box contains different items.
Sample below using DataGridView:
//DataGridView
dataGridView1.Columns.Add("Item", "Item");
dataGridView1.Columns.Add("Value", "Value");
dataGridView1.Columns.Add("Type", "Type");
dataGridView1.Columns.Add("Options", "Options");
list = new List<string[]>();
list.Add(new string[] { "Result", "DropDown", "Pass,Failed" });
list.Add(new string[] { "UserId", "Text", "" });
index = 0;
foreach (string[] s in list)
{
dataGridView1.Rows.Add(s[0], "", s[1], s[2]);
switch (s[1])
{
case "DropDown":
DataGridViewComboBoxCell cmb = new DataGridViewComboBoxCell();
var selection = s[2].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
cmb.DataSource = selection;
this.dataGridView1.Rows[index].Cells[1] = cmb;
break;
case "Text":
this.dataGridView1.Rows[index].Cells[1].Value = "Text Field";
break;
}
index++;
}