I have multiple (> 10) TextBoxes that are used to store monetary values. As the user types, I want to format the input as a currency.
I could create one method for every TextBox but that means the creation of > 10 methods. I would rather create one method that multiple TextBoxes may use. For example:
private void OnCurrencyTextBox_PreviewTextInput(object sender,
TextCompositionEventArgs e)
{
CurrencyTextBox.Text = FormattedCurrency(CurrencyTextBox.Text);
}
However, this would only work for a TextBox named CurrencyTextBox. Of course there would need to be other checks for if the key is a digit etc but for the purpose of this question I am focusing on how I can apply one method to multiple TextBoxes.