如何计算每行中datagridview中的行数 [英] how to count the number of rows in datagridview each row wise

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

问题描述

示例如下datagridview;





RK Mk CK VK Gs VB CNN UNNI SK总计(列名)



REO PH2 MFA CTF TFC LSG Tasco HK MK 9



REO PH2 TASCO TFC LGTF ECDIS MFA CTF TFC 9 < br $>




i希望每行明智。



输出我想要如下



第1排共9

第2排共9



9 to显示在总列中。我可以明智地得到每一行的总数。



我该怎么办。



它是w windows applciation。

example as follows in datagridview;


RK Mk CK VK Gs VB CNN UNNI SK Total (column name)

REO PH2 MFA CTF TFC LSG Tasco HK MK 9

REO PH2 TASCO TFC LGTF ECDIS MFA CTF TFC 9


i want each row wise total.

output i want as follows

1st row total 9
2nd row total 9

9 to be displayed in the total column.how can i get the total each row wise.

for that how can i do.

it is w windows applciation.

推荐答案

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rowcount.aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.columncount.aspx [ ^ ]


如果你想这样做



1.创建gridview的rowcreated事件

2.总结所需的griview列

3.将其绑定在网格视图中所需的行位置

你完成了



如果你不能对经过测试的代码做这个回复
if you want do it like this

1.create rowcreated event of gridview
2. sum desired columns of griview
3.bind it in desired row location in grid view
you are done

if u can not do this reply for tested code


将datagridview的数据源存储在一个列表中,然后只计算你在列表中有多少项。



Store the datasource of the datagridview in a list, then just count how many items you have in the list.

List<string> list = dataGridView1.DataSource;
int numberOfItems = list.Count();</string>


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

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