?
Solved

painting individual datagridview cells in visual c#

Posted on 2006-10-21
2
Medium Priority
?
3,366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
e1v earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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