C# clear button

Status
Not open for further replies.

Digital_Jedi

In Runtime
Messages
141
Location
Amarillo, Texas
I have never used C# before but we have to use it for my GUI class and I cannot figure out how to get a button to clear a form. I just need to reset the form back to normal when you first run the debug.
 
You need to be more specific in your questions, since "clear a form" is ambiguous. However, I'll try to answer your question making the following assumptions:
- You're using Windows Forms and not WPF
- "Clear a form" means clear text from a text box or text boxes

In the button click event handler, you need to call the "Clear" method on each text box. You can find the name of each text box by right clicking on it and selecting "Properties" from the context menu. A property grid will open up in Visual Studio if it is not already opened. You can find the variable name in the grid.

So, for each text box, you'll need to do something like the following:
Code:
void Button_Click(object sender, EventArgs e)
{
    textBox1.Clear();
    ....
}
 
Status
Not open for further replies.
Back
Top Bottom