N
NvrBst
How does "e.CellStyle" work?
When I do something like
if(e.ColumnIndex == 0 && e.RowIndex == 0)
DataGridView.Rows[0].DefaultCellStyle.BackColor = Color.Orange;
then the entire table goes orange; not just the 1st row. When I do
if(e.RowIndex == 0) e.CellStyle.BackColor = Color.Orange;
then 1st row goes orange only. Is it better to set the
"DefaultCellStyle" for a row in the "CellFormatting" event handler or
is that way of thinking wrong and just use "e.CellStyle".
I ask that because when I interate through the entire table in a load
event (not using CellFormating Event)
"DataGrideView[i,ii].DefaultCellStyle.BackColor = Color.Orange;" then
it takes about 25 seconds. Making "DataGridViewCellStyle cstyle = new
DataGridViewCellStyle(); cstyle.backcolor = color.orange;" with the
interation method brings it down to 3 seconds.
But for the "CellFormatting" event, using the "e.CellStyle.BackColor =
color.orange" takes about 3 seconds, and making a global "cstyle" and
doing "e.CellStyle = cstyle;" still takes 3 seconds. Does
CellFormating event automatically reuse a "DataGrideViewCellStyle"
object thus I don't have to do it myself. And is this resuing
property the reasion why my entire table goes orange when i do
"DataGridView.Rows[0].DefaultcellStyle.BackColor = Color.Orange;" for
the 1st cell, in the CellFormating event handler method?
Thanks Again again for your time. I've asked a lot of DataGridView
questions today already.
NB
When I do something like
if(e.ColumnIndex == 0 && e.RowIndex == 0)
DataGridView.Rows[0].DefaultCellStyle.BackColor = Color.Orange;
then the entire table goes orange; not just the 1st row. When I do
if(e.RowIndex == 0) e.CellStyle.BackColor = Color.Orange;
then 1st row goes orange only. Is it better to set the
"DefaultCellStyle" for a row in the "CellFormatting" event handler or
is that way of thinking wrong and just use "e.CellStyle".
I ask that because when I interate through the entire table in a load
event (not using CellFormating Event)
"DataGrideView[i,ii].DefaultCellStyle.BackColor = Color.Orange;" then
it takes about 25 seconds. Making "DataGridViewCellStyle cstyle = new
DataGridViewCellStyle(); cstyle.backcolor = color.orange;" with the
interation method brings it down to 3 seconds.
But for the "CellFormatting" event, using the "e.CellStyle.BackColor =
color.orange" takes about 3 seconds, and making a global "cstyle" and
doing "e.CellStyle = cstyle;" still takes 3 seconds. Does
CellFormating event automatically reuse a "DataGrideViewCellStyle"
object thus I don't have to do it myself. And is this resuing
property the reasion why my entire table goes orange when i do
"DataGridView.Rows[0].DefaultcellStyle.BackColor = Color.Orange;" for
the 1st cell, in the CellFormating event handler method?
Thanks Again again for your time. I've asked a lot of DataGridView
questions today already.
NB