Hi,
I would like to manage the display value for numeric column like this : if the cell value is 1000 then i want to display 1K, if cell value is 1000000 => 1M ...
is there a way to do that ?
Thanks
Sim
SR
Sri Rajan
Syncfusion Team
July 25, 2008 01:14 PM UTC
Hi Sim,
Thank you for your interest in Syncfusion products.
There is no direct way to do this. but you can achieve this by handling TableControlPrepareViewStyleInfo event. Here is the code.
void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlPrepareViewStyleInfoEventArgs e)
{
string str = e.Inner.Style.Text;
if (e.Inner.Style.Text.Contains("000") && e.Inner.Style.Text.Length==4)
{
str=str.Replace("000", "K");
e.Inner.Style.Text = str;
Console.WriteLine(str);
}
if (e.Inner.Style.Text.Contains("000000") && e.Inner.Style.Text.Length == 7)
{
str=str.Replace("000000", "M");
e.Inner.Style.Text=str;
}
}
Please let me know if this helps.
Best Regards,
Srirajan.
SK
Simon Kakon
July 25, 2008 03:05 PM UTC
Thanks for the response, but it can't works because the column is of type Int32.
>Hi Sim,
Thank you for your interest in Syncfusion products.
There is no direct way to do this. but you can achieve this by handling TableControlPrepareViewStyleInfo event. Here is the code.
void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlPrepareViewStyleInfoEventArgs e)
{
string str = e.Inner.Style.Text;
if (e.Inner.Style.Text.Contains("000") && e.Inner.Style.Text.Length==4)
{
str=str.Replace("000", "K");
e.Inner.Style.Text = str;
Console.WriteLine(str);
}
if (e.Inner.Style.Text.Contains("000000") && e.Inner.Style.Text.Length == 7)
{
str=str.Replace("000000", "M");
e.Inner.Style.Text=str;
}
}
Please let me know if this helps.
Best Regards,
Srirajan.
SR
Sri Rajan
Syncfusion Team
July 28, 2008 07:09 AM UTC
Hi Sim,
Thank you for your continued interest in Syncfusion products.
A Int32 DataType field does not supports characters. If you want to display format like 1K or 1M in a cell, then you need to change the datatype of the field as string. Please refer the sample code for more details.
dt.Columns.Add("Amount", typeof(string));
Please let me know if this helps.
Best Regards,
Srirajan.