/// <summary>
        /// 创建新Entity
        /// </summary>
        /// <returns></returns>
        protected virtual object AddNewItem()
        {
            System.Data.DataView dv = this.DisplayManager.Items as System.Data.DataView;
            if (dv != null)
            {
                //System.Data.DataRow row = dv.Table.NewRow();
                //dv.Table.Rows.Add(row);
                //return row;

                System.Data.DataRowView rowView = dv.AddNew();
                rowView.EndEdit();
                return(rowView);
            }
            return(null);
        }
示例#2
0
        public virtual void EndEdit(bool cancel)
        {
            if (mEditingRow == null)
            {
                return;
            }

            if (cancel)
            {
                mEditingRow.CancelEdit();
            }
            else
            {
                mEditingRow.EndEdit();
            }

            mEditingRow = null;

            //when CancelEdit the DataView doesn't automatically call a ListChanged event, so I will call it manually
            if (cancel)
            {
                OnListChanged(new System.ComponentModel.ListChangedEventArgs(System.ComponentModel.ListChangedType.Reset, -1));
            }
        }