Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataGridView EndEdit() problem
Message
 
À
25/06/2007 13:05:19
Jeff Corder
Ambit Technologies, LLC
Missouri, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01235401
Message ID:
01235533
Vues:
15
Jeff,

>I have a mmDataGridView with AllowUserToAddRow = True. It is bound to InvoicesItems which is a child of the primary table Invoices.
>
>When I open the form, the Invoices business object is populated. No changes are made to the InvoicesItems business Object. I close the form and I get an error: There is no row at position 0
>
>When I follow the error, I end up in mmBusinessForm.EndEdit(). When it calls EndEdit() on the individual rows for InvoicesItems, it gets a Position = 0 from this.BindingContext[...].Position, but there is are no rows in the table. When it calls dt.Rows[0].EndEdit() it throws an error because there is no row at position 0.
>
>It looks like the Grid is reporting its position at row 0 because that is where the cursor is and data will be entered. But, since data has not been entered, no row has been created.

Ouch...the BindingContext manager shouldn't be reporting back position 0 in this case. It should be reporting -1. I haven't seen this happen before...is there anything unusual about this form?

We can add code to EndEdit() that checks if there are any rows before calling EndEdit()...even though we shouldn't have to.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform