Thread: C# clear button
View Single Post
Old 10-01-2008, 11:16 AM   #2 (permalink)
jaeusm
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 585

jaeusm is on a distinguished road

Default Re: C# clear button

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();
    ....
}

jaeusm is offline