The while row wasn't redrawn when we change the column's value
FeaturedHi Team,
I am not sure that the bellows is the issues… but I would like to inform you.
The question concerns the method PaintRow() and updating the value using internal editors.
Here is the part of code:
…
gridHeader.Add(new Column("State", "State", 50, ContentAlignment.MiddleLeft));
grid.Headers[0]["State"].Editable = true;
..
grid.PaintRow += this.OnGridPaintRow;
…
private void OnGridPaintRow(object sender, PaintRowEventArgs e)
{
if( e.Row.DataObject is ParitetStrategyTraker ) {
ParitetStrategyTraker s = e.Row.DataObject as ParitetStrategyTraker;
if( s.State == StrategyStatus.Filled ) {
e.Appearance.BackColor = Color.FromArgb(241, 253, 219);
}
else if( s.State == StrategyStatus.Pending ) {
e.Appearance.BackColor = Color.FromArgb(241, 0, 0);
}
}
}
public class ParitetStrategyTraker
{
public StrategyStatus status;
…
}
We are using standard editor for enum types.
As result, when I change the value in “State” column from “None” to “Pending” only one(!?) cell was redrawn with new color.
I should click somewhere on the grid to make the while row to be redrawn.
Why the while row wasn't redrawn in reaction of the change of the value?
BR,
dx2003
20120913.1500.dapfor.png
-
Hi,
We think you use the event-driven model and when the ParitetStrategyTraker.State property is changed, the object raises a protertychanged event with the “State” argument. Once the grid receives the notification, it computes cell’s rectangle to be invalidated and then calls Control.Invalidate(Rectangle) method. This method can be called multiple times consecutively. Windows creates a clip region and sends WM_PAINT message. Inside of the painting routine all changes will be effective only for the required area. When you click somewhere in the grid, it changes selection or focused rows and therefore can call Row.Invalidate() for different rows. When the next WM_PAINT message is dispatched to grid, the clip region will combine surfaces of multiple rows. That’s why you see changes.
To resolve your problem, you should indicate what part of the row needs to be repainted. The best way to do it - send a NotifyPropertyChanged notification with empty or null field. In this case the grid will repaint the entire row. Or you can send multiple NotifyPropertyChanged() with affected fields. Note, if you use BindingList and send notifications with non-existing properties, you can have performance issue. Use the ThreadSafeBindingList instead. Get more details here:
http://www.dapfor.com/en/net-suite/net-grid/tutorial/threadsafe-bindinglist
Best regards,
Dapfor
0 -
Thank you!
You have made the best grid for real-time applications!
BR,
dx2003
0 -
We are very grateful for your appreciation of our product. Thank you.
0
Please sign in to leave a comment.
Comments
3 comments