Solved

painting individual datagridview cells in visual c#

Posted on 2006-10-21
2
3,314 Views
Last Modified: 2008-01-09
i am creating a datagridview that is populated like this:

DataGridViewRow Row = new DataGridViewRow();
Row = new DataGridViewRow();

DataGridViewCell[] Cells = new DataGridViewCell[2];

Cells[0] = new DataGridViewTextBoxCell();
Cells[0].Value = " ";
Cells[1].Style.BackColor = Color.FromArgb(0, 0, 0);
Cells[1] = new DataGridViewTextBoxCell();
Cells[1].Value = " ";
Cells[1].Style.BackColor = Color.FromArgb(0, 0, 0);

Row.Cells.AddRange(Cells);
dataGridView1.Rows.Add(Row);

and later in the code, this datagridview gets populated with data. when the cell gets populated with data, the cell will change color. when there is no data for the cell, it will revert back to the previous color.

the problem i am facing is there are 1000 rows in this datagridview, and when i change the color on some of the cells (reverting the color back) it seems to be painting the whole datagridview every time...i can see the whole datagridview flicker when it updates.

so my question is:
how can i JUST paint the individual cell and not the whole datagridview when one cell changes color?

thanks in advance.
0
Comment
Question by:jumpmanjay
2 Comments
 
LVL 6

Accepted Solution

by:
e1v earned 500 total points
ID: 17787092
You could try do set DoubleBuffered true for your dataGridView, but since it's a protected property you have derive from datagridview and use the derived datagridview.

public class CustomDataGridView : DataGridView
{
  public CustomDataGridView() : base()
  {
    base.DoubleBuffered = true;
  }
}

This will reduce flickering a lot, but it's not answering your question since the whole visible datagridview still updates (noticeable on slow systems).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now