New Row in DataGridView

  • Thread starter Thread starter David McWright
  • Start date Start date
D

David McWright

Hello All,
I have a DataGridView bound to a BindingSource whose DataSource is
a List<T>. If the List<T> has any items in it, the DataGridView
correctly creates columns appropriate for T and shows the data.
Additionally, it shows the "new row" at the bottom. However, if the
List<T> is empty, say before any user data is entered, then there is
no "new row". Can any one suggest a way to get the "new row" showing?

Best Regards,
David
 
David said:
Hello All,
I have a DataGridView bound to a BindingSource whose DataSource is
a List<T>. If the List<T> has any items in it, the DataGridView
correctly creates columns appropriate for T and shows the data.
Additionally, it shows the "new row" at the bottom. However, if the
List<T> is empty, say before any user data is entered, then there is
no "new row". Can any one suggest a way to get the "new row" showing?

So if the List<T>.count = 0, then add a empty new row to the collection
-- List<T>.Add(row), before you bind it.
 
So if the List<T>.count = 0, then add a empty new row to the collection
-- List<T>.Add(row), before you bind it.

Thanks for the response. I had tried that; however, if I add a new
row, then there will be two empty rows, the one I added and the "new
row." Is the solution to set DGV.AllowUserToAddRows = false until the
row I added becomes dirty and then set it to true? (I'm going to try
this, but I'm wondering if it's the right solution. )

Thanks Again,
David
 
Back
Top