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

Foreign Currency

7 Answers 806 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Evan
Top achievements
Rank 1
Evan asked on 26 Sep 2007, 12:29 AM
Is there support for changing the format of a textbox to a currency other than the US dollar?  I would like to be able to do this dynamically.

Thanks

7 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 26 Sep 2007, 09:38 AM
Hi Evan,

The currency format and symbol are controlled by the CurrentCulture property of the current thread. So, yes, you can change the current culture to another one:

    System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-gb");



Sincerely yours,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Evan
Top achievements
Rank 1
answered on 26 Sep 2007, 04:44 PM
Thanks Chavdar,

But where do I put that code?  I should state that I'm creating a webpage in asp.net with c#.

I've copied it to the Page_load event, but it does not effect the report.

I'm also trying:

Telerik.Reporting.TextBox txt = (Telerik.Reporting.TextBox)ReportViewer1.Report.Items["txtTotalCost"];

txt.Format = "{0:¥# ##0.00}";

But I get a "Object reference not set to an instance of an object" error.  This method would work best for me as the currency symbol needs to change but not the date format.

Thanks
0
Chavdar
Telerik team
answered on 26 Sep 2007, 05:22 PM
Hi Evan,

I'm attaching a sample application (web application project) which illustrates a more sophisticated approach. Let me now if you need any further assistance.

Best wishes,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Evan
Top achievements
Rank 1
answered on 26 Sep 2007, 05:51 PM
Thanks Chavdar,

I've download the project and ran it, but I'm not seeing how you accomplished this.   THere is very little code in default.aspx.cs and only one textbox on report1.cs with no value in the value property.  I'm not sure what you did?
0
Chavdar
Telerik team
answered on 26 Sep 2007, 07:52 PM

Hi Evan,

The main idea is to implement an event handler for the ItemDataBound event of the TextBox report item. Here is the code which is executed:

             void textBox1_ItemDataBound(object sender, System.EventArgs e)
        {
            Processing.TextBox currencyTextBox = (Processing.TextBox)sender;
            DataRowView rowView = (DataRowView)currencyTextBox.DataItem;

            CultureInfo ci = new CultureInfo((string)rowView["CultureInfo"]);
            double value = (double)rowView["CurrencyValue"];
            currencyTextBox.Text =
                string.Format(ci, "{0:C2}", value);
        }

Hope this helps.

Greetings,

Chavdar

Тhe Telerik team


Instantly find answers to your questions at the new Telerik Support Center
0
Evan
Top achievements
Rank 1
answered on 26 Sep 2007, 07:57 PM
Thanks Chavdar,

That's great.  Works like a charm. 

How do get this procedure to be able to read the culture choice of user for the "parent" asp page that contains this report?

0
Chavdar
Telerik team
answered on 26 Sep 2007, 08:22 PM
Hi Evan,

You can learn more about localization/globalization from the following article: How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization.

To be more helpful in your case we'll need some more detailed information about what you are trying to achieve. In general both approaches should be enough to help you accomplish your task.

Regards,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Evan
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Evan
Top achievements
Rank 1
Share this question
or