I am getting an error when I try to select a record in an mmDataGrid on a mmMaintenanceForm and delete it using the mmButtonDelete. My BizObj's DataSet has a single table in it with one record (just one row in the mmDataGrid). When I delete the record, after I verify that I want to delete it, I get the error,
No value at index -1.
The stack trace is,
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at System.Windows.Forms.CurrencyManager.get_Current()
at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.GetCurrentRow(DataSet ds, String tableName)
at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Delete(mmBusinessObject bizObj, String tableName)
at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Delete(mmBusinessObject bizObj)
at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Delete()
at OakLeaf.MM.Main.Windows.Forms.mmMaintenanceForm.btnDelete_Click(Object sender, EventArgs e)
…
All framework's GetCurrentRow method has in it is,
return (DataRowView)this.BindingContext[ds, tableName].Current;
BindingContext is a property that mmMaintenanceForm inherits from from .NET's WinForm class.
From tracing through the code, the call to mmBusinessForm.Delete(mmBusinessObject bizObj, String tableName) which calls to mmBusinessForm.GetCurrentRow(DataSet ds, String tableName) happens twice: once before the delete confirmation dialog and once after. The record is actually getting deleted from the DataBase.
I am not really sure what the problem is. If anyone is familiar with this problem, or has some suggestions for how to proceed, I would appreciate it.
David S. Alexander
Kettley Publishing
20271 SW Birch Street, 2nd Floor
Newport Beach, CA 92660-1752