private void Edit() { if (dataGridViewEvent.SelectedRows.Count != 1) { return; } EventBase even = this.dataGridViewEvent.SelectedRows[0].DataBoundItem as EventBase; int index = this.EventList.IndexOf(even); //保持当前事件对象的副本,用于在编辑事件之后,进行Compare提取差异 EventBase oldEvent = even.Clone() as EventBase; //FormEventEditor.Event编辑后还是原对象的引用,在原对象基础上修改的 FormEventEditor formEventSet = new FormEventEditor(this._hostEntity, even); //这里暂时还能用using,因为窗体释放时,会把事件的编辑面板也释放掉,要另外处理这个问题 //using (FormEventEditor formEventSet = new FormEventEditor(this._entity, even)) //{ formEventSet.FormEntity = this.FormEntity; formEventSet.EventList = this.EventList; if (formEventSet.ShowDialog() == DialogResult.OK) { //CheckWarning IWarningable warningable = formEventSet.Event as IWarningable; if (warningable != null) { warningable.CheckWarning(); } _eventBindingList.ResetItem(index); EventUpdate(); if (this.OnEdited != null) { CollectionEditEventArgs args = new CollectionEditEventArgs(this.EventList, CollectionEditType.Edit, index, formEventSet.Event); args.Members.Inject(ObjectCompare.Compare(oldEvent, formEventSet.Event)); OnEdited(this, args); } } //} }