示例#1
0
        private void dgvWebsites_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (!IsAddingNewItem && !IsCellValueChanged)
            {
                return;
            }

            int              colIndex = e.ColumnIndex;
            int              rowIndex = e.RowIndex;
            IWebsite         website  = websites[rowIndex];
            ValidationResult vr       = ContextMenuEvent.Invoke(EventType.RowValidating, new ContextMenuEventArgs()
            {
                RowIndex    = rowIndex,
                ColumnIndex = colIndex,
                Website     = website
            });

            if (!vr.IsSuccessfull)
            {
                ShowErrorMessage(vr.Message, "Error!");
                e.Cancel = true;
            }
            else
            {
                IsAddingNewItem    = false;
                IsCellValueChanged = false;
            }
        }
示例#2
0
        private void tsmiAdd_Click(object sender, EventArgs e)
        {
            if (ContextMenuEvent == null || !ContextMenuEvent.Invoke(EventType.BeginAdding, new ContextMenuEventArgs()).IsSuccessfull)
            {
                return;
            }

            dgvWebsites[0, dgvWebsites.Rows.Count - 1].Selected = true;
            IsAddingNewItem = true;
            dgvWebsites.BeginEdit(true);
        }
示例#3
0
        private void tsmiDelete_Click(object sender, EventArgs e)
        {
            int index           = dgvWebsites.CurrentCell.RowIndex;
            ValidationResult vr = ContextMenuEvent.Invoke(EventType.Remove, new ContextMenuEventArgs()
            {
                RowIndex = index
            });

            if (!vr.IsSuccessfull)
            {
                ShowErrorMessage(vr.Message, "Error!");
            }
        }
示例#4
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     ContextMenuEvent.Invoke(EventType.Exit, new ContextMenuEventArgs());
 }