如何使用c#计算数据网格中的总行数 [英] how to count the total number of rows in a datagrid using c#

查看:114
本文介绍了如何使用c#计算数据网格中的总行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用c#计算数据网格中的总行数的代码是什么,显示标签中的总数。当你点击按钮时,搜索必须返回在标签中找到的行数不返回0(零)。

解决方案

如果你在windows中使用datagridview它会工作应用

 lbl_row.Text = dataGridView1.RowCount.ToString(); 


for Winforms,它:

 datagridview.Rows.Count 





对于silverlight DataGrid,请参考:如何在加载网格后获得Silverlight Datagrid行数? [ ^ ]

和此: Silverlight DataGrid行数 [ ^ ]


使用RowCount的属性来获取数据网格视图中的行数。

请参阅下面的代码

  int  noOfRows = dataGridView1.RowCount; 
MessageBox.Show(noOfRows.ToString());


what is the code for count the total number of rows in a datagrid using c#, displaying the total number in the label. when u click the button search must return the number of rows found in the lable not return 0 (zero).

解决方案

It works ,if you are using datagridview in windows application

lbl_row.Text = dataGridView1.RowCount.ToString();


for Winforms, its:

datagridview.Rows.Count



For silverlight DataGrid, refer this : How do I get Silverlight Datagrid row count after grid is loaded?[^]
and this: Silverlight DataGrid Row count[^]


Use Property of RowCount to get the number of rows in a Data Grid View.
see the code below

int noOfRows = dataGridView1.RowCount;
MessageBox.Show(noOfRows.ToString());


这篇关于如何使用c#计算数据网格中的总行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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