windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-917ceadf.md
Returns the number of visible Grid records.
Namespace : DevExpress.XtraGrid.Views.Grid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public override int RowCount { get; }
Public Overrides ReadOnly Property RowCount As Integer
| Type | Description |
|---|---|
| Int32 |
The number of visible Grid rows.
|
This property overrides the BaseView.RowCount property to increment its value in these cases:
Note
Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the RowCount member must not be invoked for these Views. The RowCount member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.
The code sample below illustrates how to paste a clipboard value into all cells under the “TargetColumn” column.
private void gridView_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
if (e.Control && e.KeyCode == System.Windows.Forms.Keys.V) {
var text = Clipboard.GetText();
for (int i = 0; i < gridView.RowCount; i++) {
if (gridView.IsDataRow(i)) {
this.gridView.SetRowCellValue(i, "TargetColumn", text);
e.Handled = true;
}
}
}
}
'INSTANT VB NOTE: This code snippet uses implicit typing. You will need to set 'Option Infer On' in the VB file or set 'Option Infer' at the project level.
Private Sub gridView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
If e.Control AndAlso e.KeyCode = System.Windows.Forms.Keys.V Then
Dim text = Clipboard.GetText()
For i As Integer = 0 To gridView.RowCount - 1
If gridView.IsDataRow(i) Then
Me.gridView.SetRowCellValue(i, "TargetColumn", text)
e.Handled = True
End If
Next i
End If
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the RowCount property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-gridlookupedit-multiple-item-selection/CS/Form1.cs#L100
foreach(string val in values) {
for(int i = 0; i < view.RowCount; i++) {
if(view.GetRowCellValue(i, fieldName).ToString() == val)
winforms-grid-select-detail-rows-when-selecting-master-row/CS/MasterDetailSelectionHelper.cs#L28
int masterRowHandle = _GridView.SourceRowHandle;
if (_GridView.GetSelectedRows().Length == _GridView.RowCount)
{
winforms-reporting-create-grid-based-report/CS/ConvertGridToReportExample/Form1.cs#L57
dTable.Columns.Add(c.FieldName, c.ColumnType);
for (int r = 0; r < gridView.RowCount; r++)
{
winforms-gridlookupedit-multiple-item-selection/VB/Form1.vb#L97
For Each val As String In values
For i As Integer = 0 To view.RowCount - 1
If Equals(view.GetRowCellValue(i, fieldName).ToString(), val) Then selection.Add(i)
winforms-grid-select-detail-rows-when-selecting-master-row/VB/MasterDetailSelectionHelper.vb#L24
Dim masterRowHandle As Integer = _GridView.SourceRowHandle
If _GridView.GetSelectedRows().Length = _GridView.RowCount Then
TryCast(_GridView.ParentView, GridView).SelectRow(masterRowHandle)
winforms-reporting-create-grid-based-report/VB/ConvertGridToReportExample/Form1.vb#L50
Next c
For r As Integer = 0 To gridView.RowCount - 1
See Also