New Row in DataGridView

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
 
M

Mr. Arnold

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.
 
D

David McWright

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top