M
Mike Kearl
I am databinding a winforms textbox using the following
this.txtSalesRepCollected.DataBindings.Clear();
this.txtSalesRepCollected.DataBindings.Add("Text", this.dataset.table,
"SalesRepcollected");
When it returns the value from the database it returns a double value of
120.000
How can I format this so that it is only 120.00
Somone suggested that it is quite simple and that I just extend the TextBox
and handle Format / Parse events but I dont know how to do this.
I tried the following:
this.txtSalesRepCollected.Text =
double.Parse(this.txtSalesRepCollected.Text).ToString("0.00");
This works when the value comes from the databae and formats the value
correctly but if I try to type something in it messes up the number.
this.txtSalesRepCollected.DataBindings.Clear();
this.txtSalesRepCollected.DataBindings.Add("Text", this.dataset.table,
"SalesRepcollected");
When it returns the value from the database it returns a double value of
120.000
How can I format this so that it is only 120.00
Somone suggested that it is quite simple and that I just extend the TextBox
and handle Format / Parse events but I dont know how to do this.
I tried the following:
this.txtSalesRepCollected.Text =
double.Parse(this.txtSalesRepCollected.Text).ToString("0.00");
This works when the value comes from the databae and formats the value
correctly but if I try to type something in it messes up the number.