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
JS
Jeba S
Syncfusion Team
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.
AP
Aditi Pisal
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.
HA
haneefm
Syncfusion Team
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
AP
Aditi Pisal
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
HA
haneefm
Syncfusion Team
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