Solved

painting individual datagridview cells in visual c#

Posted on 2006-10-21
2
3,323 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Exceptions 3 46
Entity Framework 7 43
C#  Radio button search for Date not DateTime 4 46
Jquery/JSON passing value from one function to another 12 38
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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