I have a WPF application with a Grid
where there are multiple TextBox
s. How I can make every TextBox.Text = null;
with a button click?
Give this a try:
private void button1_Click(object sender, RoutedEventArgs e)
{
foreach (UIElement control in myGrid.Children)
{
if (control.GetType() == typeof(TextBox))
{
TextBox txtBox = (TextBox)control;
txtBox.Text = null;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With