Date Validation Failure
Hi,
I'm currently trying to handle date validation within a cell and when validation fails the focus doesn't seem to set back to the cell properly.
If you see in the attached project when an invalid date is entered, for example 6/ , a message box is displayed. I'd like for the cursor to be placed back in the cell and the user to be able to type again. Right now we're forced to click the cell again in order to enable editting.
I have also tried handling the TableControlCurrentCellConfirmChangesFailed event to call BeginEdit(true); on the cell but this does not work.
DateValidation0.zip
I'm currently trying to handle date validation within a cell and when validation fails the focus doesn't seem to set back to the cell properly.
If you see in the attached project when an invalid date is entered, for example 6/ , a message box is displayed. I'd like for the cursor to be placed back in the cell and the user to be able to type again. Right now we're forced to click the cell again in order to enable editting.
I have also tried handling the TableControlCurrentCellConfirmChangesFailed event to call BeginEdit(true); on the cell but this does not work.
DateValidation0.zip
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
November 10, 2006 12:26 PM UTC
Hi Paulo,
We will work out for a solution and let you know the details soon. Thanks for being patience.
Best regards,
Haneef
We will work out for a solution and let you know the details soon. Thanks for being patience.
Best regards,
Haneef
AD
Administrator
Syncfusion Team
November 21, 2006 03:53 PM UTC
Any word on this yet?
AD
Administrator
Syncfusion Team
November 23, 2006 05:37 AM UTC
Hi Paulo,
Our apologies for the delay in response.
You can handle the CurrentCellValidating event and use the MoveTo method to activate the currentcell. Here is a code snippet
private void gridGroupingControl1_TableControlCurrentCellValidating( object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e )
{
if ( e.TableControl.CurrentCell.Renderer.StyleInfo.CellValueType == typeof( DateTime ) )
{
object cellVal = e.TableControl.CurrentCell.Renderer.ControlValue;
string cellText = e.TableControl.CurrentCell.Renderer.ControlText;
if ( ( cellVal == null )
&& ( ( cellText != String.Empty )
|| ( cellText != null ) ) )
{
MessageBox.Show( "error" );
e.Inner.Cancel = true;
int row = e.TableControl.CurrentCell.RowIndex;
int col = e.TableControl.CurrentCell.ColIndex;
e.TableControl.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.SetFocus);
}
}
}
Sample : ModifiedWindowsApplication3.zip
Best Regards,
Haneef
Our apologies for the delay in response.
You can handle the CurrentCellValidating event and use the MoveTo method to activate the currentcell. Here is a code snippet
private void gridGroupingControl1_TableControlCurrentCellValidating( object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e )
{
if ( e.TableControl.CurrentCell.Renderer.StyleInfo.CellValueType == typeof( DateTime ) )
{
object cellVal = e.TableControl.CurrentCell.Renderer.ControlValue;
string cellText = e.TableControl.CurrentCell.Renderer.ControlText;
if ( ( cellVal == null )
&& ( ( cellText != String.Empty )
|| ( cellText != null ) ) )
{
MessageBox.Show( "error" );
e.Inner.Cancel = true;
int row = e.TableControl.CurrentCell.RowIndex;
int col = e.TableControl.CurrentCell.ColIndex;
e.TableControl.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.SetFocus);
}
}
}
Sample : ModifiedWindowsApplication3.zip
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
November 23, 2006 10:20 PM UTC
This appears to work. Thank you
SIGN IN To post a reply.
- 4 Replies
- 1 Participant
-
AD Administrator
- Nov 9, 2006 08:38 PM UTC
- Nov 23, 2006 10:20 PM UTC