1
votes

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

2

2 Answers

1
votes

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

0
votes

If you place the grid in an update panel it will repaint but no screen refresh.

     <asp:ScriptManager runat="server" ID="ScriptManager1" >
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:DataGrid ID="DataGrid1" runat="server">
                <Columns>
                    <asp:BoundColumn HeaderText="SomeColumn1" DataField="SomeColumn1" />
                    <asp:BoundColumn HeaderText="SomeColumn2" DataField="SomeColumn2" />
                    <asp:BoundColumn HeaderText="SomeColumn3" DataField="SomeColumn3" />
                </Columns>
            </asp:DataGrid>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="DataGrid1" />
        </Triggers>
     </asp:UpdatePanel>