Goober Goober - 1 year ago 92
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download