C
CanAnn
Guest
I have three textboxs the first contains a $$ and does not get bound until the third textbox is completed, I would like to format the first box when it has lost the focus, as well as when displaying the record - can anyone suggest the best method to use.. (lost focus does not seem to work).
//Formatted fields
this.txtNetAmount.DataBindings.Clear();
Binding b4 = new Binding("Text", this.bsHeader, "APINHAMOUNTNET", true);
b4.Format += new ConvertEventHandler(this.hnDisplayAmount);
this.txtNetAmount.DataBindings.Add(b4);
--------------------------------------------------------------------------------------------------------------
private void hnDisplayAmount(object sender, ConvertEventArgs cevent)
{
// The method converts only to string type. Test this using the DesiredType.
if (cevent.DesiredType != typeof(string )) return;
{
try
{
// cevent.Value = ((double)cevent.Value).ToString("{0:0.00}");
cevent.Value = string.Format("{0:0.00}", cevent.Value);
}
catch { } //do nothing
}
}//----------------------------------------------------------------------------------
Continue reading...
//Formatted fields
this.txtNetAmount.DataBindings.Clear();
Binding b4 = new Binding("Text", this.bsHeader, "APINHAMOUNTNET", true);
b4.Format += new ConvertEventHandler(this.hnDisplayAmount);
this.txtNetAmount.DataBindings.Add(b4);
--------------------------------------------------------------------------------------------------------------
private void hnDisplayAmount(object sender, ConvertEventArgs cevent)
{
// The method converts only to string type. Test this using the DesiredType.
if (cevent.DesiredType != typeof(string )) return;
{
try
{
// cevent.Value = ((double)cevent.Value).ToString("{0:0.00}");
cevent.Value = string.Format("{0:0.00}", cevent.Value);
}
catch { } //do nothing
}
}//----------------------------------------------------------------------------------
Continue reading...