how can i reset form's controls

Hi i'm doing an application that have a form i use it for imput data in a database, i like that after event buttun_click the form return as it was before the interaction of customer.

Now i close and re-open the form but is possible that no exists another method to do this

Sorry for my english but i don't have opportunity to write in this language.



Answer this question

how can i reset form's controls

  • Helge Shep

    no good
  • Santosh Thankachan

    Sorry for late reply.

    Assuming that the active form is "FmyForm.cs"

    try this in your event / after user input

    this.Hide();

    FmyForm form = new FmyForm();

    form.ShowDialog();

    I use this code to reset my form

    hope it works



  • pwang

    VB code:

    For Each Controllo In TabPage1.Controls ' for form in action Me.Controls

    If Controllo.GetType.ToString.Equals("System.Windows.Forms.TextBox") Then

    TexBox = Controllo

    TexBox.Test = ""

    End If

    Next

     

     


  • vbMark

    Following code is written in C#, i think VB Implementation will also be same

    for (int i = 0; i < this.Controls.Count; i++)
    {
    this.ControlsIdea.ResetText();
    }

    /* Iterate through Form Controls , and by using the ResetText() Function will set the text of all the controls to its default value */

    Hope this might help



  • Shawn de Wet

    Im not sure what you are trying do.

    try Application.Restart();



  • G Balaji

    Following code is written in C#, i think VB Implementation will also be same

    for (int i = 0; i < this.Controls.Count; i++)
    {
    this.Controls[ i ].ResetText();
    }

    /*Iterate through Form Controls, and by using the ResetText() Function will set the text of all the controls to its default value*/

    Hope this might help




  • Padmanabha

    I try to explain my problem with more clearly:

    I have a form with texbox, combobox ecc... i like that after an event the form return as it was when it was opened

    sorry i use vb.2005


  • _John Reynolds_

    You would need to store the status of the controls when the form first began.

    Essentially, you need a "Reset" function.

    e.g. If a textbox starts off with a text property value of "Begin," after the user makes changes to the text box and an event is fired that causes a reset to take place, in the reset function you'd need to simply set it back to "Begin".

    One simple way to do this would be to use th "Tag" property of controls. Have the tag property store the initial value when the form begins. When user hits reset, just reinitialize the controls property display value to the value in the Tag property.

  • Sandy Gallagher

    so no exists a function or class that can reset the controls in a form... ok i'll try your way.. thank's a lot.
  • how can i reset form's controls