AD
Administrator
Syncfusion Team
September 21, 2006 04:25 AM UTC
Hi John,
You can handle the DrawCellDisplayText event of the grid and set the e.DisplayText to some new value to want to display. Use the e.Style.CellIdentity.RowIndex and e.Style.CellIdentity.ColIndex to get the row and column of the cell for which the displaytext has to be set. Below is a code snippet.
private void DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if(e.Style.CellIdentity.ColIndex == 1 && e.Style.CellIdentity.RowIndex > 0 && e.DisplayText != null && e.DisplayText != string.Empty )
{
double dvalue = Double.Parse(e.Style.CellValue.ToString());
e.DisplayText = String.Format("{0:#,##0,,.0MB}",dvalue) ;
}
}
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
September 21, 2006 01:10 PM UTC
Hi Haneef,
Thank you, but that is not quite what I''m looking for. I want the value to be displayed and input in millions, but I want the grid to convert the value and store it in the underlying data source as the actual value.
For example, when the user sees [1,000] in the grid, the underlying value is [1,000,000,000] (i.e. the display value times one million). The user should then be able to change the cell value to [2,000], which would have the effect of persisting [2,000,000,000] to the underlying data source. Both the display and the input should be properly transformed when interacting with the data source.
Thanks for your continued assistance.
>Hi John,
You can handle the DrawCellDisplayText event of the grid and set the e.DisplayText to some new value to want to display. Use the e.Style.CellIdentity.RowIndex and e.Style.CellIdentity.ColIndex to get the row and column of the cell for which the displaytext has to be set. Below is a code snippet.
private void DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if(e.Style.CellIdentity.ColIndex == 1 && e.Style.CellIdentity.RowIndex > 0 && e.DisplayText != null && e.DisplayText != string.Empty )
{
double dvalue = Double.Parse(e.Style.CellValue.ToString());
e.DisplayText = String.Format("{0:#,##0,,.0MB}",dvalue) ;
}
}
Let me know if this helps.
Best Regards,
Haneef