GridListControl as CellType

if a have an string array but i want to use the GridListControl as a dropdown instead of using a choicelist how do i specify this.

what do i put for:

DataSource
DisplayMember
ValueMember

thks,
ak

2 Replies

AD Administrator Syncfusion Team November 14, 2006 11:04 AM UTC

Hi Adam,

You can convert the string array into datatable and load the datatable to the gridlistcontrol celltype. Here is a code snippet.

//QueryCellInfo event
e.Style.CellType="GridListControl";
e.Style.DataSource = ct; ///ct is coverted from string[] to Datatable.
e.Style.DisplayMember = "ChoiceListColumn";
e.Style.ValueMember = "ChoiceListColumn";

private DataTable ConvertToTable(string[] cString)
{
DataTable dTable = new DataTable("StringArray");
dTable.Columns.Add("ChoiceListColumn");
foreach(string sValue in cString)
{
DataRow dr = dTable.NewRow();
dr[0] = sValue;
dTable.Rows.Add(dr);
}
return dTable;
}

Sample : http://www.syncfusion.com/Support/user/uploads/DropDownScListControl_b388dc61.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team November 14, 2006 08:12 PM UTC

thats what i am doing and (and it works) but i thought there might be an more elegant solution.

thks,
ak

>Hi Adam,

You can convert the string array into datatable and load the datatable to the gridlistcontrol celltype. Here is a code snippet.

//QueryCellInfo event
e.Style.CellType="GridListControl";
e.Style.DataSource = ct; ///ct is coverted from string[] to Datatable.
e.Style.DisplayMember = "ChoiceListColumn";
e.Style.ValueMember = "ChoiceListColumn";

private DataTable ConvertToTable(string[] cString)
{
DataTable dTable = new DataTable("StringArray");
dTable.Columns.Add("ChoiceListColumn");
foreach(string sValue in cString)
{
DataRow dr = dTable.NewRow();
dr[0] = sValue;
dTable.Rows.Add(dr);
}
return dTable;
}

Sample : http://www.syncfusion.com/Support/user/uploads/DropDownScListControl_b388dc61.zip

Best Regards,
Haneef

Loader.
Up arrow icon