views:

28

answers:

2

How can I stop a DataGridView from re-painting the whole grid when a new row is added? Can this be done?

A: 

I'm not sure if SuspendLayout/ResumeLayout would help with this. It's really for control layout but might be worth trying since it's quick and easy.

Otherwise the way to be able to control this would be to make it virtual (set VirtualMode to true). How to: Implement Virtual Mode in the Windows Forms DataGridView Control

And here's a step by step walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control

ho1
You've actually managed to successfully get closer to my specific problem. If you use virtual mode, you'll notice that whenever the RowCount is set (and rows are added/removed from the grid), the currently visible cells are re-painted. This is behavior I would like to avoid under certain conditions. I'd assume that the grid gets invalidated due to rows being added/removed, causing all visible cells to become invalidated as well.
demius
A: 

Suspend/Resume layout won't stop the updates. Virtual may work. If it doesn't what you want is the equivalent of listbox or treeview's 'BeginUpdate/EndUpdate' properties.

But it doesn't have them. Something that looked promising: http://www.dotnet247.com/247reference/msgs/54/274004.aspx

FastAl