-
February 18th, 2010, 07:47 AM
#1
[RESOLVED] DataGridView not painting itself correctly
I have this code:
Code:
private void GetErrors()
{
errors = GetFailedTasks();
for (int i = 0; i < errors.Count; i++)
{
Task t = errors[i];
if(gridAlerts.Rows.Count <= i)
gridAlerts.Rows.Add(new DataGridViewRow());
gridAlerts["_ID", i].Value = t.ID;
gridAlerts["_Severity", i].Value = t.Severity;
gridAlerts["_Customer", i].Value = t.Customer;
gridAlerts["_Unit", i].Value = t.Unit;
gridAlerts["_IP", i].Value = t.IP;
gridAlerts["_Type", i].Value = t.Type;
gridAlerts["_Limit", i].Value = t.LimitString;
gridAlerts["_Time", i].Value = t.TimeString;
gridAlerts["_Message", i].Value = t.Message;
switch (t.DownColor)
{
case "red":
gridAlerts["_Severity", i].Style = red;
break;
case "yellow":
gridAlerts["_Severity", i].Style = yellow;
break;
case "green":
gridAlerts["_Severity", i].Style = green;
break;
}
}
for (int i = gridAlerts.Rows.Count - 1; i >= errors.Count; i--)
gridAlerts.Rows.RemoveAt(i);
}
which is executed every 2 seconds on my form. Whenever the code adds or removes one or more rows, it ends up looking like this:
I've tried:
Code:
gridAlerts.UpdateCellValue(cell, row);
gridAlerts.Update();
gridAlerts.CommitEdit();
But nothing has made any difference.
The point of manipulating the rows like this is to maintain the scrollbar position...
Does anyone have a suggestion?
It's not a bug, it's a feature!
-
February 19th, 2010, 06:06 AM
#2
Re: DataGridView not painting itself correctly
Solved: The datagridview's defaultcellstyle contained some transparent colors, which were the cause of the problems
It's not a bug, it's a feature!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|