本文介绍了如何使用DataGridViewImageColumn增强DataGridView的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我有一个DataGridView,其中包含其中一列为DataGridViewImageColumn的列。但是当我打开包含停靠DataGridView的表单时,需要很长时间才能加载。



我的第一个解决方案是将DataGridView设置为VirtualMode,尽管有一个主要的表单加载速度的改进(现在表单立即加载,但你可以看到DataGridView逐个创建单元格)。



无论如何都要加速加载DataGridView需要多长时间?



PS



在VirtualMode的CellValueNeeded事件中DataGridView我计算创建DataGridViewTextBoxColumn(00:00:00)和DataGridViewImageColumn(00:00:00.0468001)所需的时间



我从资源中获取图像C#项目中的文件夹,每个图片的尺寸为23x23。



更多背景...

我所拥有的是5个不同的图像。每个都引用当前在行中定义的项目的差异状态。我将始终使用其中一个图像,从不在维护程序计划中包含超过5个图像或少于这5个图像。



进度...每次我声明5个Image对象时,我都不会从资源文件夹中获取图像,而是将其用作图像。现在的时间如下来创建单元格......一个DataGridViewTextBoxColumn(00:00:00)和DataGridViewImageColumn(00:00:00.0370001)

Ok so I have a DataGridView that contains columns one of them being a DataGridViewImageColumn. But when I open the form containing the docked DataGridView it takes a long time to load.

My first solution was to set the DataGridView to VirtualMode and although there was a major improvement on the speed the form takes to load (now the form loads instantly but you can see the DataGridView creating the cells one by one).

Is there anyway to speed up the time it takes the DataGridView to load?

P.S.

In the CellValueNeeded Event of the VirtualMode DataGridView I timed the time it takes to create a DataGridViewTextBoxColumn ( 00 : 00 : 00) and DataGridViewImageColumn (00 : 00 : 00.0468001)

I get my images from the resource folder in the C# project and each image has dimensions 23x23.

Little more background...
What I have is 5 difference images. Each referring to a difference status on the item currently defined in the row. I will always use one of these images and never in the maintenance of the program plan to include more than 5 images or less than these 5 images.

Progress... Instead of getting the images from the resources folder every time I have declared 5 Image objects and I am using then as the images. The time now is as follows to create the cells...a DataGridViewTextBoxColumn ( 00 : 00 : 00) and DataGridViewImageColumn (00 : 00 : 00.0370001)

推荐答案



这篇关于如何使用DataGridViewImageColumn增强DataGridView的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 02:05