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. Image for the cookie policy date

which event of Grid List Control can be used to change row color?

Hi, I have to change the color of a row to red in grid list control based on bound criteria. One more How can apply the format string to a column in this control. Thanks and Regards, Kalicharan Boorugu.

3 Replies

AD Administrator Syncfusion Team August 16, 2004 01:29 AM

I am not sure what you mean by bound criteria. But to change the backcolor of a row in a gridListConttrol, you can subscribe to gridListControl1.Grid.QueryCellInfo. There, if e.RowIndex points to the row you want to color, then set e.Style.BackColor to your color. As far as applying a format string to a column, you can use teh same QueryCellInfo event. If you set teh style.Fromat, you will also have to set teh style.CellValueType so the grid knows what type you are trying to format.
private void grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
	if(e.RowIndex == 2 && e.ColIndex > 0)
	{
		e.Style.BackColor = Color.Red;
	}
	else if(e.RowIndex > 0 && e.ColIndex == 1)
	{
		e.Style.Format = "##.##";
		e.Style.CellValueType = typeof(double);
	}
}

                     

KA kalicharan August 16, 2004 09:09 AM

I did the same way suggested. But when I am clicking on the grid it is not displaying anything in the grid. Strange problem, just a Mathematical Symbol with Triangles is getting displayed. What could be reason. This the code I have written. switch(e.ColIndex) { case 1: e.Style.Format = "HH00"; e.Style.CellValueType = typeof(System.DateTime); break; case 2: // if(Convert.ToInt32(glcViewAppts.Grid[e.RowIndex, 2].Text) < 1 ) // { // glcViewAppts.BeginUpdate(); // glcViewAppts.Grid[e.RowIndex, 1].BackColor = Color.Red; // glcViewAppts.EndUpdate(); // } break; }


AD Administrator Syncfusion Team August 16, 2004 10:58 AM

Here is a sample where it seems to be working ok for me. What are you doing differently? GridListControlSample_8439.zip

Loader.
Live Chat Icon For mobile
Up arrow icon