什么是最好的方式来遍历datagridview [英] What is the best way to traverse datagridview

查看:109
本文介绍了什么是最好的方式来遍历datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以发表一些提示,说明什么是循环使用dataGridView的最佳方法?我有一个datagridview有大量的行,想要通过并获取单元格值。我使用惯例,花费时间太长。谢谢提前。

解决方案

示例代码遍历:

  foreach(DataGridView1.Rows中的DataGridViewRow行){
object [] obj = new object [row.Cells.Count]; (i = 0; i< = row.Cells.Count - 1; i ++){
obj [i] = row.Cells(i).Value; //放置你的代码并做类型转换
}
}


Could someone post some tips on what is the best way to loop through the dataGridView? I've a datagridview with large number of row and want to go through and get the cell values. I use the convention way and it take too long. Thanks in advance.

解决方案

Sample code to traverse:

foreach (DataGridViewRow row in DataGridView1.Rows) {
    object[] obj = new object[row.Cells.Count];
    for (i = 0; i <= row.Cells.Count - 1; i++) {
        obj[i] = row.Cells(i).Value; //Place your code and do type conversion
    }
}

这篇关于什么是最好的方式来遍历datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆