The textbox should only accept numbers and one . value.
However, with my code, the input of numbers is also rejected as soon as I put a dot. I don't understand why, because in the if loop I do a check if the char I entered is a dot.
private void TextBox_BeforeTextChanging(TextBox sender, TextBoxBeforeTextChangingEventArgs args)
{
args.Cancel = args.NewText.Any(c => !char.IsDigit(c) && ".".IndexOf(c) != 0);
if (args.NewText.Any(c => c == '.' && sender.Text.IndexOf('.') > -1))
{
args.Cancel = true;
}
}