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

Validate empty input in new cells

Thread ID:





21832 Nov 24,2004 06:59 AM UTC Nov 24,2004 08:15 AM UTC WinForms 1
Tags: GridControl
Michael Mann
Asked On November 24, 2004 06:59 AM UTC

Hi, I want to validate empty input and show an error message when input is equals to "". So, I use the CurrentCellValidating event and cancel the event if necessary. This works only when the cell was initially set to something other than an empty string(""). But in my case: the CurrentCellValidating event isn''t triggered and even if sometimes, the RejectChanges prevents the event from being triggered the next times. I do the following: Add a row with 3 cells, and set the input into the first cell: gridTemplates.Focus(); gridTemplates.CurrentCell.MoveTo(row, 1); gridTemplates.CurrentCell.Activate(row, 1, GridSetCurrentCellOptions.ScrollInView); When the edited cell wasn''t edited and the user intended to go to the next cell, the CurrentCellValidating event isn''t triggered. This only happens if I initially set the cells''s value (CurrentCellRenderer.ControlValue) to something. Next, when I press the escape key, this doesn''t work either. Any hints how I can get to this? Thanks in advance Michael

Administrator [Syncfusion]
Replied On November 24, 2004 08:15 AM UTC

Here is a general idea. It may need a little tweaking as you try to implement it. Try handling grid.CurrentCellMoving. In your handler, check if grid.CurrentCell.IsModified is false (which means your user did not change anything, and may be trying the leave an empty cell). In this case, if grid[grid.CurrentCell.RowIndex, grid.CurrentCell.ColIndex].Text is empty, the set grid.CurrentCell.ErrorMessage and set e.Cancel = true.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon