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.

Validate empty input in new cells

Thread ID:

Created:

Updated:

Platform:

Replies:

21832 Nov 24,2004 01:59 AM Nov 24,2004 03:15 AM Windows Forms 1
loading
Tags: GridControl
Michael Mann
Asked On November 24, 2004 01:59 AM

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 03:15 AM

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.

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.

;