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?
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.
Text = DataGridView1. RowCount it display the number of row populated with some data.
You can use DataGrid.Items.Count
to get the number if items.
store the count in a variable
int num=dataGrid.Items.Count
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With