コード例 #1
0
        private void dataGridViewSwitches_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            var row = dataGridViewSwitches.Rows[e.RowIndex];

            if (row.IsNewRow)
            {
                return;
            }
            string reason;

            if (LocalSwitch.IsValid(row.Cells, out reason))
            {
                row.ErrorText = "";
            }
            else
            {
                row.ErrorText = "Switch parameters invalid: " + reason;
                e.Cancel      = true;
            }
        }
コード例 #2
0
        private void cmdOK_Click(object sender, EventArgs e) // OK button event handler
        {
            // Place any validation constraint checks here

            Switch.traceState = chkTrace.Checked;
            Switch.switches.Clear();
            // update the switch list
            foreach (DataGridViewRow row in dataGridViewSwitches.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                string reason;
                if (LocalSwitch.IsValid(row.Cells, out reason))
                {
                    Switch.switches.Add(new LocalSwitch(row.Cells));
                }
                else
                {
                    row.ErrorText = "Invalid row contents: " + reason;
                }
            }
        }