I have a textbox where the user enters a number, but how can i make it so that if they type the \'.\' after it it only allows 2 decimal places?
private void
To address Casperah's comment above you can change the conditional to handle control characters and allow editing if text is selected.
if (!char.IsControl(e.KeyChar) && Regex.IsMatch(textBox1.Text, @"\.\d\d") && String.IsNullOrWhiteSpace(textBox1.SelectedText)) { e.Handled = true; }