| | | 
StrataFrame 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 |
| | | | 
Advanced StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 4:54:54 PM Posts: 551, Visits: 10,431 |
| | Hey, Rogério... Great!  Valeu...  |
| |
|
|