コード例 #1
0
        void gridParam_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex != colGroupNo.Index && e.ColumnIndex != colCount.Index)
            {
                return;
            }

            string value = e.FormattedValue.ToString();

            if (value == string.Empty)
            {
                return;
            }

            //check if group and count are non-negative integers (exception: DefIL allows for decimals for parameters + and -)
            string errorText     = string.Empty;
            string parameterName = e.ColumnIndex == colCount.Index ? string.Empty : dgvParameter.Rows[e.RowIndex].Cells[colParameter.Index].Value.ToString();

            if (!ParameterValidation.ValidateGroupInput(value, parameterName, ref errorText))
            {
                Tools.UserInfoHandler.ShowError(errorText);
                e.Cancel = true;
            }
            else
            {
                if (dgvParameter.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue != e.FormattedValue)
                {
                    dgvParameter.Rows[e.RowIndex].Cells[colAdd.Index].Value = true; //automatically select param if group or count is changed
                }
            }
        }