how to reorder columns in multicolumncombobox

i am playing with multicolumncombobox.
i am data-binding an array of custom created objects as a data-source and their public properties show as column (as the documentation says).

how do i choose the order in which the columns appear? it is not related to the order the properties are declared in the source...

1 Reply

JA JayaLakshmi Syncfusion Team June 14, 2007 03:45 AM UTC

Hi Kamen,

Thank you for using Syncfusion products.

You can achieve the reordering of the columns by storing the column information in a Hashtable and by handling Grid_PrepareViewStyleInfo event.

Here is the code snippet.

this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);

Hashtable hash = new Hashtable();
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
if (hash.Contains(e.ColIndex))
{
if (hash[e.ColIndex] != null)
{
e.Style.CellValueType = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].CellValueType;
e.Style.Text = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].Text;
}
}
}

Please refer the sample in the below link and let me know if this helps.

http://websamples.syncfusion.com/samples/Tools.Windows/F61776_1/main.htm

Regards,
Jaya

Loader.
Up arrow icon