Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Row Count for WPF DataGrid?

Tags:

How to count or return the last index of a DataGrid row? Apparently there's isn't a DataGrid.Count() property. I searched everywhere and I can't find an answer.

I could create a variable and use i++ as a counter for Row count, but doesn't a DataGrid has a built-in solution?

like image 514
KMC Avatar asked Apr 05 '11 07:04

KMC


People also ask

How to get DataGrid row count in WPF?

The DataGrid in WPF has not Row concept, it is Item. So if you want to get the Row counts, you could get the Item counts, like: the rowCount = DataGrid. Items.

How can I count rows in Datagridview in VB net?

Text = DataGridView1. RowCount it display the number of row populated with some data.


2 Answers

You can use DataGrid.Items.Count to get the number if items.

like image 163
Greg Sansom Avatar answered Oct 10 '22 21:10

Greg Sansom


store the count in a variable

 int num=dataGrid.Items.Count
like image 32
RajnathKumar Avatar answered Oct 10 '22 21:10

RajnathKumar