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.
Unfortunately, activation email could not send to your email. Please try again.

CurrentCellValidating event

Thread ID:

Created:

Updated:

Platform:

Replies:

22913 Dec 29,2004 04:22 AM Dec 31,2004 04:15 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 29, 2004 04:22 AM

Hi, Im my application the currentcellvalidating event is being called twice once i try to move out of a cell. I am not able to figure out why. private void m_SlbGridDSC_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e) { m_CurrentCol = m_SlbGridDSC.CurrentCellInfo.ColIndex; m_CurrentRow = m_SlbGridDSC.CurrentCellInfo.RowIndex; float val; if (m_CurrentRow > 0 && ( m_CurrentCol >=m_LengthIndex - 1 && m_CurrentCol <= m_LinearWeightIndex - 1 ) && 0 != m_SlbGridDSC.CurrentCell.Renderer.ControlText.ToString().Length ) { m_Saved = false; prevVal = m_SlbGridDSC[m_CurrentRow,m_CurrentCol].Text; try { val = float.Parse(m_SlbGridDSC.CurrentCell.Renderer.ControlText.ToString() ); if( val <= 0 ) { DisableControls(); m_LblMessage.ImageIndex = 0; m_LblMessage.Text = ERR_POSITIVE_VAL; m_ButtonOK.Visible = true; m_ButtonOK.Enabled = true; } else { if ( m_ODIndex - 1 == m_CurrentCol ) { if ( m_SlbGridDSC[m_CurrentRow,m_IDIndex - 1].Text.Length > 0 ) { if( val <= float.Parse(m_SlbGridDSC[m_CurrentRow,m_IDIndex - 1].Text)) { DisableControls(); m_LblMessage.ImageIndex = 0; m_LblMessage.Text = ERR_OD_GREATERTHAN_OD; m_ButtonOK.Visible = true; m_ButtonOK.Enabled = true; } } } else if ( m_CurrentCol == m_IDIndex - 1 ) { if ( m_SlbGridDSC[m_CurrentRow,m_ODIndex - 1].Text.Length > 0 ) { if( val >= float.Parse(m_SlbGridDSC[m_CurrentRow,m_ODIndex - 1].Text)) { DisableControls(); m_LblMessage.ImageIndex = 0; m_LblMessage.Text = ERR_ID_LESSTHAN_OD; m_ButtonOK.Visible = true; m_ButtonOK.Enabled = true; } } } } } catch( FormatException ) { m_LblMessage.ImageIndex = 0; m_LblMessage.Text = ERR_NUMERIC_VAL; DisableControls(); m_ButtonOK.Visible = true; m_ButtonOK.Enabled = true; } } } This is how i am handling the CurrentCellValidating function. Can you help?

Administrator [Syncfusion]
Replied On December 29, 2004 04:49 AM

CurrentCellValidating is normally hit only once. Are you subscribing to this event twice (somehow - say in VB you have both a Handles clause and a AddHandler statement??)? You can put a stop at the top of your CurrentCellValidating code, and then examine both call stacks when this stop is being hit twice. That may shed some light on what is triggering the double call. I am not sure what you DisableControls call does, but this might trigger a second validate call. Checking callstack would pick this out. (Stepping through the code in your CurrentCellValidating handler would also pick this up if you leave the stop at the while you step. If you own our source code and use our Assembly Manager to build and set up for use, debug versions of our libraries, then th call stack would include our library code as well.

Administrator [Syncfusion]
Replied On December 31, 2004 02:57 AM

I can find out the cause of the problem. The CurrentCellValidatingEvent is being fired twice because i am setting the Enabled property of GridControl to false in the Disablecontrols functions. My requirement is if the user does not enter a valid message then i need to display an error message in a message area which i have created. The message area has a OK button . So until the user clicks on OK button the grid cannot get focus. Imagine a case when you show messages using MessageBox.Show method. But i cannot use pop up windows showing error messages. I have to display the error message in the message area. Can you please tell how can i overcome this problem?

Administrator [Syncfusion]
Replied On December 31, 2004 04:15 AM

Can you set a flag before you disable the grid?Then in CurrentCellValidating, test this flag and do not do your validation code if it is set. This way your code would only be hit once. Will this solve your problem?

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;