Hi Nancy,
Thanks for your post!
From my understanding, you want to validate the cell value when you are
moving to another grid cell.
Here is an simple sample to do this, please reply to this thread if you
still have problem on it.
Thanks !
<code>
//
private DataGridCell oldCell;
private bool cellError = false;
...
//In OnLoad event handler
ds.Tables[0].ColumnChanging += new
DataColumnChangeEventHandler(columnChanging);
grid.CurrentCellChanged += new EventHandler(cellChanged);
...
void columnChanging(object o, DataColumnChangeEventArgs e)
{
oldCell = grid.CurrentCell;
//do check
// don't allow "Test" in ContactName field.
cellError = (e.Column.ColumnName == "ContactName" &&
e.ProposedValue.ToString().ToUpper() == "TEST");
}
void cellChanged(object o, EventArgs e)
{
if (cellError)
grid.CurrentCell = oldCell;
}
</code>
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.