简体   繁体   English

WinForms DataGridView重画问题

[英]WinForms DataGridView re-painting problem

How can I stop a DataGridView from re-painting the whole grid when a new row is added? 添加新行后,如何阻止DataGridView重新绘制整个网格? Can this be done? 能做到吗?

I'm not sure if SuspendLayout / ResumeLayout would help with this. 我不确定SuspendLayout / ResumeLayout是否可以帮助您。 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). 否则,能够控制它的方法将是使其虚拟化(将VirtualMode设置为true)。 How to: Implement Virtual Mode in the Windows Forms DataGridView Control 如何:在Windows Forms DataGridView控件中实现虚拟模式

And here's a step by step walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control 这是逐步的演练: 在Windows Forms DataGridView控件中实现虚拟模式

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM