If I have a DataGridView uxChargeBackDataGridView.
Are the following syntactically different but effectively the same?:
int numRows = uxChargeBackDataGridView.Rows.Count;
int numRowCount = uxChargeBackDataGridView.RowCount;
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?
My WinForms application has a button named 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 ?
Both statements are the same. However, one thing to remember is that an “empty” datagridview has 1 record only if the
AllowUsersToAddRowproperty is set to true. Otherwise, the row count will be 0.EDIT:
I would like to add, in lieu of MMK’s answer that if you do not change the RowCount, either manually or programatically, they will return the same value. See http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rowcount.aspx.