views:

12

answers:

1

Hi everybody!

This drives me crazy:

i'm using a datagridview (bound to a dataset) and textboxes also bound to the dataset (which means that everything typed into the textboxes is reflected in the datagridview). The datagridview is actually used only to show up the values (user is NOT able to edit anything in the cells).

So: when the user pushes the add new record button (automatically created by visual studio using binding navigator etc. ) i would like to programmatically select this new line (remember: user has not the ability to select with the mouse) and insert some values.

I tried to use the

DefaultValuesNeeded 

event, but this is firing only if the user selects the row with the asterisk indicator (what the user is not allowed to do).

How can i simulate that behavior? Should i take another approach?

Thanks in advance!!

A: 

Revised:

How about the Datatable's TableNewRow event, then? If that gets fired when the BindingNavigator creates a new row, then that's an opportunity to populate the object.

Stuart Dunkeld
Hi Stuart!Thanks for the response. As the documentation correctly states "You cannot set the NewObject property when bound to a DataView or DataTable because you cannot add a new DataRowView to the list." this is the tricky part which gives me the headache (i use a dataset with data tables)!
Savvas Sopiadis
That looks better! I will give this a try and let you know! Thanks
Savvas Sopiadis