什么是最好的方式来遍历datagridview [英] What is the best way to traverse 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屋!
查看全文