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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

maskedit in cell of gridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

43341 Apr 20,2006 04:49 PM UTC Apr 24,2006 10:15 AM UTC WinForms 10
loading
Tags: GridControl
Fady Sayegh
Asked On April 20, 2006 04:49 PM UTC

hi to all, i''m using the gridControl in my win form application. i have a cell that contains a maskedit, i set the property Mask like this : oGrdC.ColStyles[i + 1].MaskEdit.Mask = "__/__/___"; when i run the program, i can''t enter data. i works only when i set the property to " / / " how can i put the first mask ("__/__/____") for the date best regards and thanks in advance fady

Administrator [Syncfusion]
Replied On April 21, 2006 03:55 AM UTC

Hi Fady, Could you try this code oGrdC.ColStyles[i + 1].CellType = "MaskEdit"; oGrdC.ColStyles[i + 1].MaskEdit.Mask = "99/99/9999"; Let me know if you need any further assistance. Regards, Haneef

Fady Sayegh
Replied On April 21, 2006 07:28 AM UTC

Hi Haneef, thanks to your reply, in fact that''s what did i do, but this 2 lines of code oGrdC.ColStyles[i + 1].CellType = "MaskEdit"; oGrdC.ColStyles[i + 1].MaskEdit.Mask = "99/99/9999"; gives this mask at run time " / / " or i need to have this one "__/__/____", in other words i need to display the underscores in the mask. but when i do that the gridControl does not accept any input from the user in the maskedit cell best regards and thanks in advance fady

Administrator [Syncfusion]
Replied On April 21, 2006 08:54 AM UTC

Hi Fady, You need to set the PaddingCharacter and PromptCharacter property of the MaskEdit Celltype in a grid.Here is a code snippet. oGrdC.ColStyles[i + 1].CellType = "MaskEdit"; oGrdC.ColStyles[i + 1].MaskEdit.Mask = "99/99/9999"; oGrdC.ColStyles[i + 1].MaskEdit.PromptCharacter = ''_''; oGrdC.ColStyles[i + 1].MaskEdit.PaddingCharacter = ''_''; Here is a sample. http://www.syncfusion.com/Support/user/uploads/welcome_966bb1ae.zip Let me know if you need any further assistance. Regards, Haneef

Fady Sayegh
Replied On April 21, 2006 10:10 AM UTC

Hi Haneef, thanks to your reply, it works but how can i verify if the date (54/26/2006)entered by the user is valid. is there a way to validate the date when the user leave the cell for example, if the date is not valid and when the user leave the cell : clear the cell best regards and thanks in advance fady

Administrator [Syncfusion]
Replied On April 21, 2006 10:49 AM UTC

Hi Fady, To validate the current cell in a grid, you need to handle grid''s CurrentCellValidateString event.Here is a code snippet GridCurrentCell cc = this.gridControl1.CurrentCell; CultureInfo culture = new CultureInfo(CultureInfo.CurrentCulture.LCID); try { DateTime.ParseExact( cc.Renderer.ControlText,"dd/MM/yyyy",culture,DateTimeStyles.AllowWhiteSpaces ); } catch { cc.RejectChanges(); } Please let me know if you have any further assistance. Thanks for your interest in Syncfusion Products. Regards, Haneef

fady sayegh
Replied On April 21, 2006 01:58 PM UTC

Hi Haneef, thanks to your reply, the code you gave work properly, but when i type an invalide date "35/35/2006" and hit the tab key nothing happens the first time, i need to hit another time the tab key so the changes will be rejected. so the changes are rejected the second time i hit the tab key and not the first time. do you have any idea to solve this issue ? best regards and thanks in advance fady

Administrator [Syncfusion]
Replied On April 24, 2006 03:45 AM UTC

Hi Fady, Could you try this code. GridCurrentCell cc = this.gridControl1.CurrentCell; CultureInfo culture = new CultureInfo CultureInfo.CurrentCulture.LCID); try { DateTime.ParseExact( cc.Renderer.ControlText,"dd/MM/yyyy",culture,DateTimeStyles.AllowWhiteSpaces ); } catch { cc.Renderer.ControlValue = string.Empty; } Thanks for your patience. Regards, Haneef

Fady Sayegh
Replied On April 24, 2006 08:51 AM UTC

Hi Haneef, thanks to your reply, the code you post work properly, but it set the cell to empty if the user enter a wrong date. but i still need the old value of the cell. for example : the value in the cell before editing is "12/12/2005", now the user enter a wrong date "35/35/2005". when the user hit the tab key i need to get back to the old date witch is "12/12/2005" and not an empty string best regards and thanks in advance fady

Administrator [Syncfusion]
Replied On April 24, 2006 09:48 AM UTC

Hi Fady, You need to use this code to get the old value of the cell in a grid.Here is a code snippet GridCurrentCell cc = this.gridControl1.CurrentCell; CultureInfo culture = new CultureInfo( CultureInfo.CurrentCulture.LCID); try { DateTime.ParseExact( cc.Renderer.ControlText,"dd/MM/yyyy",culture,DateTimeStyles.AllowWhiteSpaces ); } catch { cc.Renderer.ControlValue = this.gridControl1.Model[cc.RowIndex,cc.ColIndex].CellValue ; } Please let me know if this helps. Regards, Haneef

Fady Sayegh
Replied On April 24, 2006 10:15 AM UTC

Hi Haneef, thanks to your reply, it works fine, that''s exactly what did i want thanks again fady

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.

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

;