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

Padding 0 before a digit in GridGrouping Control

Thread ID:

Created:

Updated:

Platform:

Replies:

71144 Jan 17,2008 12:00 PM UTC Jan 28,2008 10:22 PM UTC WinForms 5
loading
Tags: GridControl
Aditi Pisal
Asked On January 17, 2008 12:00 PM UTC

Hi,

I have the following requirement:

Padding 0's before a digit in a particular column:
EX:

value of the cell given by e.style.cellvalue = 456123
I have to display it as 10 digit number like 0000456123
But the dispaly should not change the actual value of cell.
It must only dispaly in 10 -digit format.


WRN
0000456123


Thanks in Advance
Aditi


Jeba S [Syncfusion]
Replied On January 18, 2008 07:28 AM UTC

Hi Aditi,

Thank you for your interest in Syncfusion Products.

You can make use of the Format property for padding zero before a digit in GridGroupingControl.


this.gridGroupingControl1.TableDescriptor.Columns[0].Appearance.AnyRecordFieldCell.Format = "0000000000";


Kindly let us know if you need any further assistance.

Best Regards,
Jeba.




Aditi Pisal
Replied On January 21, 2008 11:53 AM UTC

Thanks Jeba,
but this solution is not working.
Can you suggest me something which can go in the querycellformatedtext event or queryvalue event,or any other event for that matter.
Thanks in Advance,
Aditi

>Hi Aditi,

Thank you for your interest in Syncfusion Products.

You can make use of the Format property for padding zero before a digit in GridGroupingControl.


this.gridGroupingControl1.TableDescriptor.Columns[0].Appearance.AnyRecordFieldCell.Format = "0000000000";


Kindly let us know if you need any further assistance.

Best Regards,
Jeba.






haneefm [Syncfusion]
Replied On January 23, 2008 08:07 PM UTC

Hi Aditi,

Another way to do this is to handle the TableControlDrawCellDisplayText and set the e.Inner.DiaplayText at that point. Below are the codes:

void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record
&& style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.MappingName == "parentID")
{
double d;
if (Double.TryParse(e.Inner.Style.CellValue.ToString(), out d))
{
e.Inner.DisplayText = string.Format("{0:0000000000}", d);
}
}
}

Best regards,
Haneef


Aditi Pisal
Replied On January 28, 2008 09:49 AM UTC

Thanks aneef,
The below solution is working fine,but I have to export this data to EXCEL and this formatting is not visisble when the data is exported to Excel.
The other formatting applied in the QueryFormattedtext and QueryCellstyleInfo is getting applied to EXCEL.
Thn why I ma not able to see this data formatting in excel ?
Kindly help asap
Thanks in Advance,
Aditi


>Hi Aditi,

Another way to do this is to handle the TableControlDrawCellDisplayText and set the e.Inner.DiaplayText at that point. Below are the codes:

void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record
&& style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.MappingName == "parentID")
{
double d;
if (Double.TryParse(e.Inner.Style.CellValue.ToString(), out d))
{
e.Inner.DisplayText = string.Format("{0:0000000000}", d);
}
}
}

Best regards,
Haneef




haneefm [Syncfusion]
Replied On January 28, 2008 10:22 PM UTC

Hi Aditi,

The reason is that TableControlDrawCellDisplayText is only used to display the formatted cell text in a grid. It doesn't store the formatted display text in a grid cell. If you want to store formatted text then you need to handle the QueryFormattedText event. Below are the codes:

void gridGroupingControl1_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
GridTableCellStyleInfo style = e.Style as GridTableCellStyleInfo;
if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record
&& style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.MappingName == "Col1")
{
double d;
if (Double.TryParse(e.Style.CellValue.ToString(), out d))
{
e.Text = string.Format("{0:0000000000}", d);
e.Handled = true;
}
}
}


Best regards,
Haneef


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

;