0

Hi there guys I just want to know how I can create a reset button that will erase all the contents written by a user in textboxes? I am creating an Enrollment Form for Students and I need some help about it. I have attached a screenshot for you guys be sure to check it. Thanks in advance!

Attachments hehehe.jpg 15.97 KB
5
Contributors
7
Replies
21
Views
6 Years
Discussion Span
Last Post by brite_a
0

Just set the Text property to string.Empty or to whatever they contained initially in the Click event handler of your reset button.

0

Just set the Text property to string.Empty or to whatever they contained initially in the Click event handler of your reset button.

sir can you show me a sample code on how to do it? thanks!

0
MyTextBox1.Text = string.Empty;
MyTextBox2.Text = string.Empty;
// etc.

theres another way of doing this:

textbox1.Clear();

thank you sir!

0

Respect to above question MytextBox1.text = string.Empty; will only work for a single instance what if i want to clear my all textbox at a single instance.

0

you could use a foreach loop to clear all textboxes within a parent control.

foreach(Control Control in Form1.Controls)
{
    if(Control is textBox)
    {
        (Control as textBox).Clear();
    }
}

If you group together the textbox in a panel/groupbox, pass in the parent control to the loop.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.