jnettleton (2) [Avatar] Offline
In all of your DataGrid examples in chapter 17, you show them w/o the last blank row (marked with *; used to add a new row). How did you disable this feature? Is it buried in (inherited from) the PhotoAlbum class and is somehow disabled when you call the SetDataBinding() method? The only thing I've found so far is something in the DataView class and setting the AllowNew property to false (but you don't cover this class in your book).

Jerry N.
eebrown (89) [Avatar] Offline
Re: DataGrid and disabling new rows

You are correct that setting the AllowNew property to false for a displayed DataView is one way to hide the "add new row" section of the DataGrid.

In our application, the DataGrid hides this automatically because our PhotoAlbum class does not support the IBindingList interface. This is where the AllowNew property and AddNew() method come from that are used by the DataGrid class to perform these functions. Since these are not available, the "add new row" is not visible.

When displaying a DataSet object, the control knows how to add a row so it displays the add. The only way I know of to disable this is to use a DataView instead and set AllowNew to false.