If I have a method that returns a datagridview and the flow is similar to this:
if (ds.Tables.Count == 0)
{
SharedMethods.updateStatus("There are no excluded results to display");
//return dgv;
}
else
{
dgv.DataSource = ds.Tables[0];
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgv.AllowUserToAddRows = false;
return dgv;
}
If the if condition is true then I do not want to return a datagridview(as there is no data), what can I return in this case? If I return null, then the calling method has a null datagridview that causes later problems.
Thanks.
Just set the grid’s Visible property to false if you have nothing to show.