Hi,
I want to change a columns background color: dgvtxbQty.DefaultCellStyle.BackColor = System.Drawing.Color.White;
But on the Grid I have a AlternatingRowsDefaultCellStyle which set every other row format.
The problem is it overides the dgvtxbQty.DefaultCellStyle.BackColor & the backcolor only works for the rows not being set by the AlternatingRowsDefaultCellStyle
Is there a way around this?
Regards
Loading
ic icPosted Sep 30, 2009, 6:28 AM
DataGridView dgv = sender as DataGridView;
e.CellStyle.BackColor = dgv.Columns[e.ColumnIndex].DefaultCellStyle.BackColor;
but unfortunately the alternatingrowdefaultcellstyle still overides it
I removed the alternatingrowdefaultcellstyle but the RowSelectionColor is now overiding the cell background color.
??
Nagesh RPosted Sep 30, 2009, 5:21 AM
DataGridviewcell cell;
and then set the background color as required...
ic icPosted Sep 30, 2009, 4:41 AM
I'm not sure how to the instance on the codebehind (i'm a beginner) - please provide some code?
I also don't have a onPreRender Event on my DatagridView?
Please Assist!
Roei BarPosted Sep 29, 2009, 2:21 PM
on the Item_Create Event you can overwrite the Color
or on Item.DataBound
or you can do it all in the OnPreRender Event, that is the Last event for the Page to load and all Controls are already there, you can then go to the GridViewObject and alter the cell colors
TrinityPosted Sep 29, 2009, 11:32 AM
define an instance of DataGridviewcell cell in your code behind and define its background color
then assign it to the DataGridColum.celltemplate property