We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

catch the message "is not a valid value for"

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?

4 Replies

MK Markus Kraft November 26, 2003 05:47 AM

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 06:21 AM

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 06:25 AM

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 06:41 AM

Yeah i found "my error", i must check against CellValue because CellValueType is always the correct type. thanks for help, now it works fine.

Loader.
Live Chat Icon For mobile
Up arrow icon