DataRow. Delete () trigger System. ArgumentOutOfRangeException: "index beyond range, must be a negative and less than the set size, Arg_ParamName_Name" code is as follows:
Private void DeleteTingRow (object sender, DataGridViewRowCancelEventArgs e)
{
Purchasedata. Rows [" e.R ow. Index]. The Delete ();
}
Baffled and here cause indexes after delete value beyond the scope of abnormal
AlertPurchaseInfo AlertPurchaseInfo=new AlertPurchaseInfo ();
AlertPurchaseInfo. Purchasenumber=purchasenumber;
AlertPurchaseInfo. ShowDialog ();
Open the modal dialog thrown exception????? Hope leaders see gives directions
CodePudding user response:
Private void DeleteTingRow (object sender, DataGridViewRowCancelEventArgs e)
{
if (" e.R ow. Index> 1) { Purchasedata. Rows [" e.R ow. Index]. The Delete (); } }
CodePudding user response:
The
reference 1/f, autumn red fruit reply: private void DeleteTingRow (object sender, DataGridViewRowCancelEventArgs e) { if (" e.R ow. Index> 1) { Purchasedata. Rows [" e.R ow. Index]. The Delete (); } } "E.R ow. As the abnormal Index value is not less than zero CodePudding user response:
Suggested that the "e.R ow. Index and purchasedata. Print the number of Rows Easy to find problems CodePudding user response:
Purchasedata. Rows should be empty ha, here have no data source? CodePudding user response:
reference xian_wwq reply: 3/f suggested "e.R. Ow Index and purchasedata. Print the number of Rows Easy to found the problem After tried also to perform the delete method through don't know why and to AlertPurchaseInfo AlertPurchaseInfo=new AlertPurchaseInfo (); AlertPurchaseInfo. Purchasenumber=purchasenumber; AlertPurchaseInfo. ShowDialog (); Then an error here CodePudding user response:
Add a judgment, the if (purchasedata Rows? . Count & gt; 0) CodePudding user response:
refer to 6th floor rabbit family - second brother reply: add a judgment, the if (purchasedata. Rows? . Count & gt; 0) delete method is executed no problem after jump out here in the open mode box code error, and after the execution of the datatable is not delete the data CodePudding user response:
AlertPurchaseInfo. ShowDialog (); Your letter the method? CodePudding user response:
You so it is difficult for us to help you find a problem, the object is a what all don't know, and run to here have to value your hair, too CodePudding user response:
You can put the issue to the whole piece of code, you this problem is the index exceeding a, 7 rows of data, 0 to 6