Windows 7上的C#Winform网格渲染速度很慢
发布时间:2020-12-14 01:55:24 所属栏目:Windows 来源:网络整理
导读:我注意到我的 Windows 7 64位机器上的C#winform datagrid非常慢.对于具有1000行足够的列/文本以适应屏幕宽度的标准网格,我看到滚动显着的渲染延迟(即滚动/滚动条移动滞后约0.5秒而不是平滑).当最大化到全屏时网格特别慢并且随着显示尺寸减小而变得更快. 通过
我注意到我的
Windows 7 64位机器上的C#winform datagrid非常慢.对于具有1000行足够的列/文本以适应屏幕宽度的标准网格,我看到滚动显着的渲染延迟(即滚动/滚动条移动滞后约0.5秒而不是平滑).当最大化到全屏时网格特别慢并且随着显示尺寸减小而变得更快.
通过将DataTable绑定到DataGridView实例,GUI是一个简单的设置;我已经研究了双缓冲等常见的罪魁祸首并没有看到太多改进.该机器在nvidia quadro nvs 420上采用Xeon四核和2 x 23英寸屏幕赢得了64位. 任何人都知道为什么会这样吗? 解决方法
尝试禁用网格的所有事件处理程序,然后查看网格的执行情况.如果它表现良好,启用一些,直到你遇到性能.即使没有网格的事件处理程序,它仍然执行缓慢,罪魁祸首可能是史蒂夫在他的回答中提到的AutoSizing.
应用程序性能是否会受到其他机器的影响它可能是需要重新安装的视频驱动程序吗? 编辑:我刚刚制作了一个测试应用程序并看到了你的问题,但是当我进行双缓冲时它就消失了? 看到这个答案: 我的完整代码,我创建了一个名为DataSet1的20列DataSet,然后我用DataGridView创建了一个简单的Windows窗体: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender,EventArgs e) { // comment out the line below for the application to lag SetDoubleBuffered(dataGridView1); for (int i = 0; i < 10000; i++) { dataSet1.DataTable1.AddDataTable1Row(GetRandomString(),GetRandomString(),GetRandomString()); } } public static void SetDoubleBuffered(System.Windows.Forms.Control c) { //Taxes: Remote Desktop Connection and painting //http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx if (System.Windows.Forms.SystemInformation.TerminalServerSession) return; System.Reflection.PropertyInfo aProp = typeof(System.Windows.Forms.Control).GetProperty( "DoubleBuffered",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); aProp.SetValue(c,true,null); } private Random rand = new Random(); private string validChars = "0123456789abcdefghijklmnopqurstuvwyz"; private string GetRandomString() { StringBuilder builder = new StringBuilder(); char[] c = new char[rand.Next(15,20)]; for (int i = 0; i < c.Length; i++) { c[i] = validChars[rand.Next(0,validChars.Length - 1)]; } return new string(c); } } } 测试了超过100,000条记录,每条记录有20列,长度从15到20不等 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows Server 2008 R2(x64) IIS7+PHP5.6.30(FastCGI)环
- /bin/sh^M: bad interpreter: No such file or directory 问
- 部署:MSI包与脚本
- windows-xp – 如何从批处理文件中的变量中删除双引号?
- windows – !堆 – 在windbg中没有显示增长的堆
- windows-server-2008 – 2008 Sever随机重启
- 如何在Windows Vista上编译为Linux / Unix编写的C源代码(给
- 什么是Windows最佳的VCS解决方案?
- 无法连接到从Windows 7运行Ubuntu的VirtualBox上安装的Redi
- windows – netbios域名重命名