This is a migrated thread and some comments may be shown as answers.

NumberFormat on column

3 Answers 139 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
James asked on 22 Sep 2010, 07:33 AM
Hello, I am using 2010 Q2


I want to display amount in Indian format on grid column.
Is it possible to assign directly using inbuilt formatting?


If not we are using below code for Microsoft Datagridview

NumberFormatInfo RupeeFormat = new NumberFormatInfo(); 
RupeeFormat.NumberGroupSeparator = ","
RupeeFormat.NumberGroupSizes = new int[] {3, 2};
//NOTE: default format for decimal type columns 
DataGridViewCellStyle DecimalStyleVal = New DataGridViewCellStyle(); 
DecimalStyleVal.FormatProvider = RupeeFormat;
DecimalStyleVal.Format = ConstantsUtils.PriceFormat; 
DecimalStyleVal.NullValue = "0.00"
DecimalStyleVal.Alignment = DataGridViewContentAlignment.MiddleRight; 


Now we are just using this on Form Load  as shown below(not handling any formatting event)

    gridview.Columns["Amount"].DefaultCellStyle = DecimalStyleVal ;

How to achive this in your grid, by assigning cellstyle only?
This is working perfectly in MS datagridview.

Display Example:
Decimal value = 12345678.95  
( required view )
Display in dgv column = 1,23,45,678.95

Or any alternative to display format as shown in example?

2) How can i apply Numberformat to your gridview column in form loading
3) If possible how to apply for Summary also.

 I have a grid showing Stock price.
Which is updating every second.
I want to apply conditional formatting on that

ConditionalFormattingObject c1 = new ConditionalFormattingObject( "Grater", ConditionTypes.Greater, "5", "", true );
c1.CellBackColor = Color.LightBlue;
c1.CellForeColor = Color.Black;
ConditionalFormattingObject c2 = new ConditionalFormattingObject( "Less", ConditionTypes.Less, "5", "", true );
c2.CellBackColor = Color.IndianRed;
c2.CellForeColor = Color.Black;
ConditionalFormattingObject c3 = new ConditionalFormattingObject( "Equal", ConditionTypes.Equal, "5", "", true );
c3.CellBackColor = Color.White;
c3.CellForeColor = Color.Black;

I am using above code for generating conditions.
However, here i am having "5" as a Value1 parameter, instead of that i want to check the same cell value with the new value for same cell

Like say, A column BidPrice have value 50 (Old value backcolor = black)
New price after 1 sec is 51 (New value)

so i want to put conditionalformatting in such a way that it should check Old value and New value for setting cell colors for price change display. in this case "c1" will be applied to the cell after new value.
Display should be BidPrice 51 ( backcolor = blue )

Hope you undderstand wat i want to ask.


3 Answers, 1 is accepted

Sort by
Telerik team
answered on 24 Sep 2010, 04:35 PM
Hello James,

Thank you for contacting us. Regarding your questions:

1. We do not support the NumberFormatInfo class in RadGridView. However, you can use the column FormatString and property to set the desired format string and the column FormatInfo property to set a proper CultureInfo. In addition, you can handle the CellFormatting event and fully customize the cell text. Here is a sample:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
    if (e.CellElement.RowElement is GridDataRowElement && e.CellElement.ColumnInfo.Name == "Value")
        e.CellElement.Text = MyCustomFormat(e.CellElement.Value);

2. When refreshing the grid, all old values will be lost. You should track them manually, for example in a separate table. When applying complex formatting, it is better to use the CellFormatting event. Please consider this help article and the "GridView >> Customize >> Formatting with Code" example in our demo application.

I hope this helps. If you have further questions, please do not hesitate to write back.

Sincerely yours,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Top achievements
Rank 1
answered on 10 Feb 2011, 02:23 PM



IntOrdervalue = Convert.ToInt64(FinalOrderValue);


OrderValue1.Text =

String.Format("{0:n}", IntOrdervalue);


am using above code in my telrik radgrid to achive numberformat, now i need to get number format on indian style with same code above but am getting someother number format.
plz hel me
Telerik team
answered on 11 Feb 2011, 10:15 AM
Hello siva,

Thank you for this question. You should use the correct CultureInfo when formatting the string. Another option is to create a custom format provider like demonstrated in this MSDN article. I hope this helps. 

Should you have any other questions, please do not hesitate to contact us. 

Kind regards,
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Top achievements
Rank 1
Share this question