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

Grid List control

Thread ID:





70259 Dec 4,2007 06:01 PM UTC Dec 4,2007 09:23 PM UTC WinForms 1
Tags: GridControl
Asked On December 4, 2007 06:01 PM UTC

I am using 2 gridlist controls in my project. There is a requirement that as soon as I select a code in the first gridlist control, it should be added to the first position in the second gridlist and the color of text in that first/top row should be different from the default color of other rows.
Thus, if I add one more record to the second gridlist control, this particular record should be shown in different color and the rest of the records should be shown in defualt color.
Is this possible in GridList control and if so then how?


haneefm [Syncfusion]
Replied On December 4, 2007 09:23 PM UTC


You can acheive this by handling the PrepareViewStyleInfo event of the gridcontrol.

The idea is to have a hashtable and in that hastable, set the ID of the datarow in the SelectedValueChanged event and check that ID in PrepareViewStyleInfo event of another gridlistcontrol to provide the color of the row. Below are codes that shows this task.

this.gridListControl2.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);

void gridListControl1_SelectedValueChanged(object sender, EventArgs e)
GridListControl ListControl = sender as GridListControl;
DataRowView dr = ListControl.SelectedValue as DataRowView;

if ( !prevHashtable.Contains(dr[0]))
DataTable dt = this.gridListControl2.DataSource as DataTable;
DataRow drow = dt.NewRow();
drow.ItemArray = dr.Row.ItemArray;
dt.Rows.InsertAt(drow, 0);

void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
if (e.RowIndex > 0 && e.ColIndex > 0)
GridControl grid = sender as GridControl;
if (prevHashtable.Contains(grid.Model[e.RowIndex, 1].CellValue))
e.Style.BackColor = Color.Coral;


Please refer to the attached sample for implementation.

Best regards,


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

or the page will be automatically redirected to 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