コード例 #1
0
ファイル: DataGridForm.cs プロジェクト: Ogiss/AbakTools
        protected virtual void CloneCurrentRow()
        {
            DataGridViewRow row = DataGrid.CurrentRow;

            if (row != null)
            {
                DialogResult result = System.Windows.Forms.DialogResult.None;
                if (row.DataBoundItem != null && row.DataBoundItem is ICloneable)
                {
                    var record = ((ICloneable)row.DataBoundItem).Clone();
                    BeforeEditRowEventArgs e = new BeforeEditRowEventArgs(record);
                    OnBeforeEditRow(e);
                    if (!e.Cancel)
                    {
                        result = EditRecord(record);
                        OnAfterEditRow(new AfterEditRowEventArgs(record));
                    }
                    else
                    {
                        result = DialogResult.Cancel;
                    }
                }

                if (result == DialogResult.OK)
                {
                    DataGrid.Refresh();
                }
            }
        }
コード例 #2
0
ファイル: DataGridForm.cs プロジェクト: Ogiss/AbakTools
 protected virtual void OnBeforeEditRow(BeforeEditRowEventArgs e)
 {
     if (BeforeEditRow != null)
     {
         BeforeEditRow(this, e);
     }
 }
コード例 #3
0
ファイル: DataGridForm.cs プロジェクト: Ogiss/AbakTools
        protected virtual void EditCurrentRow()
        {
            DataGridViewRow row = DataGrid.CurrentRow;

            if (row != null)
            {
                DialogResult result;
                if (row.DataBoundItem != null)
                {
                    object record            = row.DataBoundItem;
                    BeforeEditRowEventArgs e = new BeforeEditRowEventArgs(record);
                    OnBeforeEditRow(e);
                    if (!e.Cancel)
                    {
                        result = EditRecord(record);
                        OnAfterEditRow(new AfterEditRowEventArgs(record));
                    }
                    else
                    {
                        result = DialogResult.Cancel;
                    }
                }
                else
                {
                    result = EditRecord(row);
                }

                if (result == DialogResult.OK)
                {
                    DataGrid.Refresh();
                }
            }
        }