Re: Settings invisible field values for user created rows in DataGridView

Tech-Archive recommends: Speed Up your PC by fixing your registry



On Mar 9, 5:35 am, Marc Gravell <marc.grav...@xxxxxxxxx> wrote:
One option is to subscirbe to the AddingNew event of the
BindingSource, and set e.NewObject to whatever you want.

Alternatively - what is behind the BindingSource? If it is
BindingList<T>, you can override AddNewCore nad set what properties
you want.

Marc
Thank you for your answer.

The data source behind the DataGridView is a very simple .MDB (Access
database) which has a simple table named XXX (XXX is not the real
name) I tried to handle AddingNew as you recommended, but I don't know
what type of object should I set for the NewObject. Ideally, I don't
want to create a new object myself, I want to receive the object
(which represents the new row) created by the user when the user just
have typed a new row, and set only the value for the hidden field
while leaving all the values input by the user intact.

Anyways, I tried like
XXXDataSet.XXXRow. r = xxxDataSet.XXX.NewXXXRow();
r.HiddenField = 2;
e.NewObject = r;
but failed. I think XXXRow type is incorrect, but what type should I
set for it? Is it uncommon that setting hidden field value for newly
created row by user? I thought it should be common and there should be
already a practice for this.
.