473,396 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataGridView CellFormatting Event

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
Dec 31 '07 #1
0 4065

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David | last post by:
I have a realtime stock quote system developed where I am updating a typed dataset with realtime quotes. I want my DataGridView control to show green forecolor when a price moves up and red...
3
by: David Veeneman | last post by:
I'm trying to set images in a bound DataGridView image column. My enum has three possible values, and I have an image that I want to show for each value: EnumValue.OK --GreenLight.gif...
3
by: Prashwee | last post by:
Hello All In my windows application I am using DataGridView as my grid control. I populated let's say 10 rows of data and modified 3 random rows. I need to put some sort of Edit Marker in the...
3
by: Henry Jones | last post by:
I am using VB.NET VS 2005 and I have a datagridview bound to a table. This table has rate information on bank loans. The fiels are ProductName, MinDeposit, Rate, and PreviousRate On the grid...
2
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have an event handler on the CellFormatting event of a DataGridView. This event handler highlights cells that are below a certain threshold. This threshold value may change based on user actions....
4
by: NvrBst | last post by:
I have a log viewer. I sort the DataGridView by the Time Column and then run a function to set all cell backcolors depending if the cell above is different. This works correctly, however, when...
4
by: CGatto | last post by:
Hello, Just wondering if anyone has ever managed to find a way to have a datagridviewimagecolumn display different images on different rows depending on some data element in the row. Our...
2
by: Steve | last post by:
Hi All I am using VB.net 2005 windows forms I use the Datagridview.cellformatting event to change the colours of individual cells as required and all works fine How can I do the same for...
5
by: Ashutosh | last post by:
Hi, I have a DataGridView which has as typed data-set associated with it. For the table which I am displaying in it, I want to display certain cells (corresponding to a column in the database) to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.