CurrencyTextBox from StrataFrame TextBox
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



CurrencyTextBox from StrataFrame TextBoxExpand / Collapse
Author
Message
Posted 02/22/2008 5:36:20 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 05/07/2008 3:03:55 PM
Posts: 63, Visits: 377
Hi...

Creating a component for edition of a field currency from a class base of the StrataFrame.

Success !!!

Rogério
http://blog.licitec.com.br


using System;
using System.Collections.Generic;
using System.Text;

namespace Licitec.StrataFrame.WinForms
{
    public class CurrencyTextBox : MicroFour.StrataFrame.UI.Windows.Forms.Textbox
    {
        protected override void OnValidating(System.ComponentModel.CancelEventArgs e)
        {
            System.Globalization.CultureInfo culture;
            culture = System.Globalization.CultureInfo.CreateSpecificCulture("pt-BR");
            decimal result;

            if (this.Text.Trim() != string.Empty && !decimal.TryParse(this.Text, System.Globalization.NumberStyles.Currency, culture, out result))
            {
              
                this.HideSelection = false;
                this.SelectAll();
                System.Windows.Forms.MessageBox.Show("Entre com um valor válido.");
                this.HideSelection = true;
                e.Cancel = true;
            }

            base.OnValidating(e);
        }

        protected override void OnValidated(EventArgs e)
        {
            decimal result;
            if (this.Text.Trim() == string.Empty)
            {
                result = 0;
            }
            else
            {
                result = Decimal.Parse(this.Text, System.Globalization.NumberStyles.Currency);
            }
            this.Text = result.ToString("c");

            base.OnValidated(e);
        }

        protected override void OnEnter(EventArgs e)
        {
            System.Globalization.CultureInfo culture;
            culture = System.Globalization.CultureInfo.CreateSpecificCulture("pt-BR");
            decimal result;
            if (decimal.TryParse(this.Text, System.Globalization.NumberStyles.Currency, culture, out result))
            {
                this.Text = result.ToString();
            }

            base.OnEnter(e);
        }
    }
}


Rogério Mauri


http://blog.licitec.com.br
Post #14533
Posted 02/23/2008 10:59:14 AM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 4:54:54 PM
Posts: 551, Visits: 10,431
Hey, Rogério...

Great!

Valeu...

Post #14535
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Trent L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 1:02am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.047. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.