You would normally do user validation in CurrentCellValidating, and set e.Cancel = true if you validation fails. In this case, the grid leaves the focus on the currentcell, and you do not have to call BeginEdit.
Will this work for you?
MK
Markus Kraft
November 26, 2003 10:47 AM UTC
Hi,
in the Eventhandler ValueGrid_CurrentCellEditingComplete i check the CellValueType of validity and go on with
ValueGrid.CurrentCell.BeginEdit().
To catch the message in CurrentCellChanged, CurrentCellEditingComplete and CurrentCellValidating was not successful.
On wich place can i do my CellValueType check and return to BeginEdit() before the message "is not a valid value for" appears?
greetings markus
MK
Markus Kraft
November 26, 2003 11:21 AM UTC
Hi Clay,
in my CurrentCellValidating handler i check the CellValueType against the ColumnType of the DataSource Table.
The "e.Cancel = true" dont cancel the message.
Thats the way i do:
private void ValueGrid_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e)
{
GridBoundColumn gbcTempCol =
m_ValueGrid.Binder.InternalColumns[m_ValueGrid.Binder.ColIndexToField(m_ValueGrid.CurrentCell.ColIndex)];
DataTable dtSourceTable = m_ValueGrid.DataSource as DataTable;
if(m_ValueGrid[m_ValueGrid.CurrentCell.RowIndex,m_ValueGrid.CurrentCell.ColIndex].CellValueType
!= dtSourceTable.Columns[(string)gbcTempCol.MappingName].DataType)
{
e.Cancel = true;
}
}
Any suggestion?
markus
AD
Administrator
Syncfusion Team
November 26, 2003 11:25 AM UTC
I would think your e.Cancel is never hit.
The reason is that m_ValueGrid[m_ValueGrid.CurrentCell.RowIndex,m_ValueGrid.CurrentCell.ColIndex].CellValueType will always be the type in the gridboundcolumn.
What you should do is to get the current text (grid.CurrentCell.Renderer.ControlText), and check if that new text can be parsed for your desired CellValueType which you get from the gridboundcolumn.
MK
Markus Kraft
November 26, 2003 11:41 AM UTC
Yeah i found "my error",
i must check against CellValue because CellValueType is always the correct type.
thanks for help, now it works fine.