lanzhoulei posted on Friday, August 02, 2013
hi, all.
When I modify the sample ActionExtenderSample(C# ) solution. async save data. than throw DataGridView.IndexOutOfRangeException. I hope to get some help. Thank you.
// field
private OrderDetailCollection _details;
// constructor
_details = OrderDetailCollection.GetOrderDetailCollection();
// BindUI method
_BindingTree = BindingSourceHelper.InitializeBindingSourceTree(this.components, orderDetailCollectionBindingSource);
_BindingTree.Bind(_details);
// button click: delete item
private void button1_Click(object sender, EventArgs e)
{
var data = orderDetailCollectionBindingSource.Current as OrderDetail;
_details.Remove(data);
}
// toolSave click
private void toolSave_Click(object sender, EventArgs e)
{
SaveAsync();
}
private void SaveAsync()
{
_BindingTree.Apply();
var old = _details.Clone();
// Raise Paint event. Here will throw exception: DataGridView.IndexOutOfRangeException
// If I remove it, then no problem
orderDetailListDataGridView.Width = 300;
orderDetailListDataGridView.Height = 100;
_details.BeginSave((o, r) =>
{
if (r.Error == null)
_details = r.NewObject as OrderDetailCollection;
else
_details = old;
_BindingTree.Bind(_details);
});
}