You will need the TextChanged event.
A regular textbox takes a bit of string manipulation, something like this:
private void tb_TextChanged(object sender, EventArgs e) {
string s = tb.Text;
s = "000"+s.Replace(".", "");
int len = s.Length;
s = s.Substring(0, len-2).TrimStart('0').PadLeft(1, '0')+
"."+s.Substring(len-2,2);
tb.Text = s;
tb.SelectionStart = s.Length;
tb.SelectionLength = 0;
}
notes:
- textbox can initially be empty (does not need to be initialized to 0.00)
- does not rely on numeric conversions, so no range limitations
- works also when something gets pasted in
- does not reject unexpected characters (if needed, extra code should be added)
- textbox cursor is forced to the right
- fortunately this event only fires when the content really changes, so no event avalanche (unless the event handlers code isn't stable)
- during development it is wise to add logging and to apply a simple defense, e.g.
private void tb_TextChanged(object sender, EventArgs e) {
if (++changes>10) return;
Console.WriteLine(tb.Text);
...
}