private void HandleDataError(object sender, DataGridDataErrorEventArgs e) { System.Windows.Controls.DataGrid dg = (System.Windows.Controls.DataGrid)sender; DataGridColumn dc = dg.Columns[e.ColumnIndex]; if ((e.Context & DataGridDataErrorContexts.Parsing) == DataGridDataErrorContexts.Parsing) { if (dc.ValueType == typeof(Int32)) { System.Windows.MessageBox.Show(this, "Invalid number for " + dc.HeaderText, "Input error", MessageBoxButton.OK, MessageBoxImage.Warning); } else { System.Windows.MessageBox.Show(this, "Invalid format for " + dc.HeaderText, "Input error", MessageBoxButton.OK, MessageBoxImage.Warning); } } //else if ((e.Context & DataGridViewDataErrorContexts.Commit) == DataGridViewDataErrorContexts.Commit) //{ // MessageBox.Show(this, "You must enter a value for " + dc.HeaderText, "Input error", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} else System.Windows.MessageBox.Show(this, e.Exception.Message, "Input error", MessageBoxButton.OK, MessageBoxImage.Warning); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)