I thought that the problem I am encountering was due to the unbound RadMultiColumnComboBox.
I am using the RadMultiColumnComboBox just like the way the unbound RadMultiColumnComboBox was use in this sample.
The only difference of the solution is that the control was added to the form onruntime.
Instead of showing the value the display member has, it shows
Telerik.WinControls.UI.GridViewDataRowInfo .
Also, I get a runtime error if I clicked on the dropdown grid. But no error if I used the arrow keys to select a record.
I made a test project with this scenario. The Form is blank at startup.
Does this mean that we cannot add controls on runtime?
Below is the code.
private
void
Form1_Load(
object
sender, EventArgs e)
{
var comboBox =
new
RadMultiColumnComboBox();
this
.Controls.Add(comboBox);
comboBox.EditorControl.ShowColumnHeaders =
false
;
comboBox.DropDownStyle = RadDropDownStyle.DropDownList;
comboBox.Font =
new
System.Drawing.Font(
"Verdana"
, 9F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((
byte
)(0)));
comboBox.EditorControl.ShowHeaderCellButtons =
false
;
comboBox.EditorControl.ShowRowHeaderColumn =
false
;
comboBox.EditorControl.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
comboBox.Size =
new
Size(500, 20);
var source = SampleData();
foreach
(DataColumn dataColumn
in
source.Columns)
comboBox.EditorControl.Columns.Add(dataColumn.ColumnName, dataColumn.ColumnName);
foreach
(DataRow dataRow
in
source.Rows)
comboBox.EditorControl.Rows.Add(dataRow.ItemArray);
if
(comboBox.Columns.Contains(
"Value"
))
{
comboBox.Columns[
"Value"
].IsVisible =
false
;
comboBox.DisplayMember =
"Value"
;
comboBox.ValueMember =
"Value"
;
}
}
DataTable SampleData()
{
var dt =
new
DataTable();
dt.Columns.Add(
"Name"
);
dt.Columns.Add(
"Description"
);
dt.Columns.Add(
"Value"
);
dt.Rows.Add(
new
object
[] {
"1"
,
"Low"
,
"1 - Low"
});
dt.Rows.Add(
new
object
[] {
"2"
,
"Medium"
,
"2 - Medium"
});
dt.Rows.Add(
new
object
[] {
"3"
,
"High"
,
"3 - High"
});
return
dt;
}