DataSource and BoundList

May 28, 2009 at 1:29 PM
Edited May 28, 2009 at 1:34 PM

I have a list of objects of a specific class, for example:

List<Definition> definitions = new List<Definition>();

I bind the list:

DevAge.ComponentModel.BoundList<Definition> boundList = new DevAge.ComponentModel.BoundList<Definition>(definitions);

I set the bound list as the data source:

dataGrid.DataSource = boundList;

This displays all of the items in my list, but leaves an empty row at the end.

Lets say that the item count in the list is 4. The bound list item count returns 4. But when I check the number of rows in the dataGrid after setting the data source, it returns 6. I am guessing this number includes 1 extra row for the columns, and 1 extra row for the empty row at the end, and 4 of the actual items in the list.


I would like to get rid of that empty row at the end. Can anyone help?

May 28, 2009 at 8:24 PM

Have you tried:

boundList.AllowNew = false;

May 29, 2009 at 2:06 PM

I didn't think of that, that makes absolute sense.

I just tested it and it solves my problem, thanks for the help.

May 30, 2009 at 1:24 PM

Actually i didn't know why this line appears for two years!  Of course, i did not search for solution, but now here it is.