DataGridView的行数VS Rows.Count [英] DataGridView RowCount vs Rows.Count

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

问题描述

如果我有一个DataGridView uxChargeBackDataGridView

If I have a DataGridView uxChargeBackDataGridView.

有以下几种语法不同,但实际上是相同的:

Are the following syntactically different but effectively the same?:

int numRows = uxChargeBackDataGridView.Rows.Count;
int numRowCount = uxChargeBackDataGridView.RowCount;

如果 uxChargeBackDataGridView 为空,则两者相等为1;它因此在逻辑上站立,如果其中任一等于1,我可以假设用户没有输入任何数据?

If uxChargeBackDataGridView is empty then both are equal to 1; does it therefore logically stand that if either of these is equal to 1 I can assume the user has not input any data?

WinFroms有一个按钮运行 - 我可以用上面的测试,如果此按钮启用与否,即只启用按钮时的行号是>决定; 1

The WinFroms has a button RUN - could I use the above test to decide if this button is enabled or not i.e only enable the button when the number of rows is >1 ?

推荐答案

这两个语句是相同的。但是,有一点要记住的是一个空的datagridview只有当 AllowUsersToAddRow 属性设置为true 1的纪录。否则,行数为0

Both statements are the same. However, one thing to remember is that an "empty" datagridview has 1 record only if the AllowUsersToAddRow property is set to true. Otherwise, the row count will be 0.

编辑:
我想补充,替代MMK的回答,如果你不改变行数,手动或编程,它们将返回相同的值。请参见 http://msdn.microsoft.com/en-us/library /system.windows.forms.datagridview.rowcount.aspx

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

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