Goober Goober - 5 months ago 42
C# Question

C# DataGridView Check if empty

I have a datagridview which gets filled with data returned from a linq query.
If the query returns no results I want to display a messagebox.
Is there a way of checking to see if the datagridview is empty?

Regards

Answer Source

You can find out if it is empty by checking the number of rows in the DataGridView. If myDataGridView.Rows.Count == 0 then your DataGridView is empty.