goneWildCoder
Programmer
Hi all,
I have a ColumnChanging event attached to a dataset to perform validations. For some reason unknown to me, the event does not get fired when the user presses the 'tab' key with a null cell.
I am trying to make sure that no cell is null. When no value is entered in a cell, and the column is changed, I want the ColumnChanging event to capture it and throw a messagebox to the user. Please help.
Here is what I have -->
private void Division_ColumnChanging(object sender, System.Data.DataColumnChangeEventArgs e)
{
...
..
.
if ( (e.Column.ColumnName.Equals("Div_Code")) ||
(e.Column.ColumnName.Equals("Div_Name")) )
{
if(e.ProposedValue.ToString().Length == 0)
{
MessageBox.Show("Column " + cs.HeaderText + " cannot be null.", "SPIRIT2 - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
dataGrid1.CurrentCell = (DataGridCell) sender;
}
}
...
..
.
}
I have a ColumnChanging event attached to a dataset to perform validations. For some reason unknown to me, the event does not get fired when the user presses the 'tab' key with a null cell.
I am trying to make sure that no cell is null. When no value is entered in a cell, and the column is changed, I want the ColumnChanging event to capture it and throw a messagebox to the user. Please help.
Here is what I have -->
private void Division_ColumnChanging(object sender, System.Data.DataColumnChangeEventArgs e)
{
...
..
.
if ( (e.Column.ColumnName.Equals("Div_Code")) ||
(e.Column.ColumnName.Equals("Div_Name")) )
{
if(e.ProposedValue.ToString().Length == 0)
{
MessageBox.Show("Column " + cs.HeaderText + " cannot be null.", "SPIRIT2 - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
dataGrid1.CurrentCell = (DataGridCell) sender;
}
}
...
..
.
}