Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. reseting forms

reseting forms

Scheduled Pinned Locked Moved C#
help
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shwaguy
    wrote on last edited by
    #1

    I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form tia! shwaguy

    P M 2 Replies Last reply
    0
    • S shwaguy

      I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form tia! shwaguy

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      shwaguy wrote:

      I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form

      Excellent - now what have you done so far? How far have you got with your code - or were you wanting us to write the code for you?

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      S 1 Reply Last reply
      0
      • S shwaguy

        I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form tia! shwaguy

        M Offline
        M Offline
        Mbah Dhaim
        wrote on last edited by
        #3

        if you mean to reset the controls to its a default value for a property i.e Text you may follow this step 1. create list to buffer a property value for each controls in your form 2. get property value back to controls according its index sample

        private ArrayList initialValues = new ArrayList();
        private void StoreInitialValue()
        {
        foreach (Control ctl in YourForm.Controls)
        {
        initialValues.Add(ctl.property);
        }

        private void ResetToInitialValue()
        {
        for (int i=0; i< YourForm.Controls.Count; i++)
        {
        YourForm.Controls[i].Property = (typeof(your.stored.property.type))initialValues[i];
        }
        }
        }

        hope it helps

        dhaim programming is a hobby that make some money as side effect :)

        S 1 Reply Last reply
        0
        • P Pete OHanlon

          shwaguy wrote:

          I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form

          Excellent - now what have you done so far? How far have you got with your code - or were you wanting us to write the code for you?

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          S Offline
          S Offline
          shwaguy
          wrote on last edited by
          #4

          Thanks for the reply smart guy (AKA ass). Want a chance to redeem yourself? What I am asking is a newbie question and I have no idea how to go about reseting a whole group of textboxes. Questions I have asked myself: Is it possible? Is it a built in function of the MS C# IDE like "groupbox1.child.text = ""? looking for some help and not smart ass comments. tia shwaguy

          1 Reply Last reply
          0
          • M Mbah Dhaim

            if you mean to reset the controls to its a default value for a property i.e Text you may follow this step 1. create list to buffer a property value for each controls in your form 2. get property value back to controls according its index sample

            private ArrayList initialValues = new ArrayList();
            private void StoreInitialValue()
            {
            foreach (Control ctl in YourForm.Controls)
            {
            initialValues.Add(ctl.property);
            }

            private void ResetToInitialValue()
            {
            for (int i=0; i< YourForm.Controls.Count; i++)
            {
            YourForm.Controls[i].Property = (typeof(your.stored.property.type))initialValues[i];
            }
            }
            }

            hope it helps

            dhaim programming is a hobby that make some money as side effect :)

            S Offline
            S Offline
            shwaguy
            wrote on last edited by
            #5

            thanks dhaim! I am going to give the code example a shot

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups