Home All Groups Group Topic Archive Search About

Add value to data-bound datagridview during run-time

Author
10 Jun 2009 3:25 PM
AY Xu
Dear expert,

I've a datagridview control bound to dataset/datatable via
bindingsource.The datatable has 4 columns, 1st column hidden in
datagridview, and value was added by program during run-time, the rest
3 columns enter by user. I've set datagridview allow add/edit/delete.
I know you can't programmly add value to datagridview which bound to a
data source. The value has to be add to data   table instead.

The problem is: when I finish enter values for 3 visible columns and
leave cursor, now i got error: 1st column value null not allowed.
I've try put code in binding source event like: addingnew,
currentchanged and currentitemchanged etc. but does not work.
I think my code may have problem (sorry can't paste code here, i leave
it in office pc).
How can i reference to current editing row and which event will fire
before new row added to data table?

i use vsts 2008

Many thanks for your help!
A.Y. Xu

Author
10 Jun 2009 3:38 PM
Cor Ligthert[MVP]
Hi,

Can you see what the binding events can do for you

http://www.vb-tips.com/DataBindingEvents.aspx

Cor

Show quoteHide quote
"AY Xu" <ay***@yahoo.com> wrote in message
news:a2a73093-d871-4ada-8eb5-c8d03730a8c2@f10g2000vbf.googlegroups.com...
> Dear expert,
>
> I've a datagridview control bound to dataset/datatable via
> bindingsource.The datatable has 4 columns, 1st column hidden in
> datagridview, and value was added by program during run-time, the rest
> 3 columns enter by user. I've set datagridview allow add/edit/delete.
> I know you can't programmly add value to datagridview which bound to a
> data source. The value has to be add to data   table instead.
>
> The problem is: when I finish enter values for 3 visible columns and
> leave cursor, now i got error: 1st column value null not allowed.
> I've try put code in binding source event like: addingnew,
> currentchanged and currentitemchanged etc. but does not work.
> I think my code may have problem (sorry can't paste code here, i leave
> it in office pc).
> How can i reference to current editing row and which event will fire
> before new row added to data table?
>
> i use vsts 2008
>
> Many thanks for your help!
> A.Y. Xu