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

prefill text in a gridgroupingcontrol cell

Thread ID:





51632 Nov 9,2006 06:55 PM UTC Nov 10,2006 07:05 AM UTC WinForms 1
Tags: Tools
Manoj Bhaskarakurup
Asked On November 9, 2006 06:55 PM UTC


I am using a gridgroupingcontrol. In one of the column, I am using mask. The format I need is ####-####. Here is what I have done,
gridColumnDescriptor3.Appearance.AnyRecordFieldCell.CellType = "MaskEdit";
gridColumnDescriptor3.Appearance.AnyRecordFieldCell.MaskEdit.Mask = "####-####";
gridColumnDescriptor3.Appearance.AnyRecordFieldCell.MaskEdit.PaddingCharacter = '0';

The issue I face is, if the column has only 7 digits like 1234567 it pads with a trailing zero, so it becomes 12345670, whereas I want a padding with leading zero like 01234567.

Is there a way to do this. Let me know if you need any more information on this.


Administrator [Syncfusion]
Replied On November 10, 2006 07:05 AM UTC

Hi Manoj,

This is the default behavior of the MaskEdit cell type, however to get the desired behavior, you can use DrawCellDisplayText event and set the e.DispalyText to some new value to want to display. Here is a code snippet

private void gridDrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
if( e.Style.CellType == "MaskEdit"
&& e.Style.Text != e.DisplayText )
int iTrailZero = e.DisplayText.Length - e.Style.Text.Length;
string sTrailZero = string.Empty;
for(int i= 1;isTrailZero += '0';
e.DisplayText = sTrailZero + e.DisplayText.Substring(0,e.DisplayText.Length-iTrailZero + 1);

Best Regards,


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

or the page will be automatically redirected to 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