本文介绍了DataGridView中的最大行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当count很大时,以下语句抛出Out of Memory异常(我看到这个为count = 44百万)(注意我使用虚拟模式只填充可见单元格)

dataGrid .RowCount = count;

我想修改如下:

试试{
dataGrid.RowCount = count;
} catch(OutOfMemoryException) {

//将计数设置为合理的值
count = rational_value;

ShowMessage("仅显示{0}行",计数);
dataGrid.RowCount = count;






我的问题是:这里合理的行数是多少。 datagridview的文档并没有将任何最大值放在数据网格可以拥有的行数上,但实际上存在内存限制。解决这个问题的最佳方法是什么?

The following statement throws an Out of Memory exception when count is large (I saw this for count = 44 million) (Note that I am using virtual mode to populate only the visible cells)

dataGrid.RowCount = count;

I want to modify this as follows :

try {
    dataGrid.RowCount = count;
} catch (OutOfMemoryException){

    // set count to reasonable value
    count = reasonable_value;

    ShowMessage ("Showing only {0} rows", count);
    dataGrid.RowCount = count;

}


My question is : What is a reasonable row count here. The documentation for datagridview doesnt put any max value on the row count a datagrid can have, but in practice there is a memory limitation. What is the best way to work around this problem

推荐答案


这篇关于DataGridView中的最大行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 04:37