Update: if you use the formatter as 'n' for number, it works fine...!
The data I am getting from the database is in the RAW format. For example, if I am tracking the price of the item, it will be 23.45343 . I need to display in the form of 23.45.
I also need to take care of the rounding the values. Also, adding ',' for every thousands e.g. 1,000,000.01 But I do not need currency specifier along with it. e.g. $. I can add formats such as c, d. But I need the currency specifier removed.
I also need to handle percentages, to show, 2.1 as 2.1%
Now, I can use 'p' to format it as %, but the problem here is the data I am getting from the DB is already in %. But the number doesnt have the % sign, which I need to add to the cells.
Is it possible to do that? If yes, how?
Another Update:
The datetime data I am getting from the database is like this: "Fri Sep 05 00:00:00 EDT 2008"
I need to convert it to MM/dd/yyyy format. I have tried using format strings like d,g,etc. But I am not able to format it. Is there any way where we can manually format the data of the column?
I'll really appreciate your help in this regards.
Thanks :)
Hi Kelly,
No, they are probably about the same efficiency-wise. Assuming that you write your InitializeRow code efficiently. You might want to take a look at the WinGrid Performance Guide for some tips on that.
The real difference is that a ValueBasedApperance can be set up at Design-time without writing any code.
If you are going to do it at run-time, then InitializeRow is actually less code.
Thanks Mike,
Is using ValueBasedAppearance more effcient than using InitializeRow?
Thanks, Kelly
Kelly said:Is there a way to make it work so that the $ is left aligned and the amount is right aligned?
No, I don't believe this is possible with DotNet formatting. ToString just returns a string and it has no notion of the size of the area in which the string will be displayed. So it cannot control the alignment.
Kelly said:In excel, you can put a color indicator for positive and negative, ie [Red](#,##0.00)Is that also possible here? I tried and it didn't work, but is there a different format? Or would I just do it in initialize row?
No, as I said, the grid just uses the ToString method of the cell value and passes in the format. ToString just returns a formatted string, it contains no color information.
You can use InitializeRow for this, or you could use the ValueBasedAppearance on the column.
Another question:
The following is the Accounting format in excel: "_($* #,##0.00_);_($* -#,##0.00;_($* ""-""??_);_(@_)"
I tried translating that to this: "$* #,##0.00;$* -#,##0.00;-" but it displayed the *
This get's me close, but not with the $: "$ #,##0.00;$ -#,##0.00;-"
Is there a way to make it work so that the $ is left aligned and the amount is right aligned?