We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridListControl - Order of Columns and accessing Selected Row

Thread ID:





58736 Mar 27,2007 01:16 PM UTC Mar 27,2007 05:25 PM UTC WinForms 1
Tags: GridControl
Rahul Hans
Asked On March 27, 2007 01:16 PM UTC

I had added this post to the previous thread that I had started and I suspected that it would be lost there so I am re-posting it

Hi Saravanan

I need to have some control over the order of columns that appear in the GridListControl.

At the moment I am not able to find out on what basis does the GridListcontrol order the columns.

Just to refresh your memory I am using Gridlistcontrol as a celltype in the gridcontrol.

The datasource is a list which is populated thru a datareader.

I read some in the forumn that deriving gridlistcontrol and overriding CreateGridColumn should do the job, but that isnt working out for me.

Your previous advice helped a lot. I was also able to align and format the columns.

One more thing. How does one access in code the row selected in the GridListControl.

Thanks & Best Regards

>HI Saravanan

Thanks ! This solves two remaining issues...

It also gives me sufficient inputs to try to solve some more issues which have come up in the meanwhile

>Hi RH,

1, Change the column headings that i am getting in the dropdown gridlist.

This can be achieved by changing the cellvalues of the header cells. For this, PrepareViewStyleInfo event of the underlying gridcontrol can be used.
Here is the code snippet.
//In form load
GridDropDownGridListControlCellRenderer renderer = this.gridControl1.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer;
renderer.ListControlPart.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
if (e.RowIndex == 0)
if (e.Style.CellValue.ToString() == "col2")
e.Style.CellValue = "Column2";

2, I need to optionally hide some columns

Any columns of gridlistcontrol celltype in gridcontrol can be made hidden from the 'CurrentCellShowingDropDown' Event of gridcontrol.
Here is the code snippets.
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridDropDownGridListControlCellRenderer renderer = cc.Renderer as GridDropDownGridListControlCellRenderer;
if (renderer != null)
renderer.ListControlPart.Grid.HideCols["columnName"] = true;


Rajagopal [Syncfusion]
Replied On March 27, 2007 05:25 PM UTC

Hi RH,

Question 1:

Please refer this forum thread that discusses controlling the order of columns in GridListControl.

Question 2: Accessing selected row

You can use the code below in the CurrentCellCloseDropDown event to get the selected row in the GridListControl dropdown.

void gridControl1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e)
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer;
if (cr != null)
Console.WriteLine("Selected Value: {0}", cr.ListControlPart.SelectedValue);
DataRow dr = ((DataRowView)cr.ListControlPart.SelectedItem).Row;
Console.WriteLine("Selected RowIndex: {0}", cr.ListControlPart.SelectedIndex);

Please let us know if you need any further help.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon