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. Control won't update

Control won't update

Scheduled Pinned Locked Moved C#
helpannouncement
7 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.
  • M Offline
    M Offline
    MAW30
    wrote on last edited by
    #1

    I built a control which I try to send a value to, however the control doesn't update. What must I do to have the value update. Within the main control I have a smaller numericUpDown control. I send the value to a method within the main control. Though the value is updated programtically, it does not update on my screen. The main control is set in a tab control on my form, yet was built in a separate library where I send the value to be updated. I made this as a control because I access it in 2 separate forms. Any help would be greatly appreciated. Michael

    D 1 Reply Last reply
    0
    • M MAW30

      I built a control which I try to send a value to, however the control doesn't update. What must I do to have the value update. Within the main control I have a smaller numericUpDown control. I send the value to a method within the main control. Though the value is updated programtically, it does not update on my screen. The main control is set in a tab control on my form, yet was built in a separate library where I send the value to be updated. I made this as a control because I access it in 2 separate forms. Any help would be greatly appreciated. Michael

      D Offline
      D Offline
      Dr Walt Fair PE
      wrote on last edited by
      #2

      You didn't say what platform you are working on, but if it's WinForms, then you may need to Refresh() the control for the changes to be visible. If the program is busy doing other things, you may also need to use Application.DoEvents() to process any Windows messages that force the refreshing.

      CQ de W5ALT

      Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

      M 1 Reply Last reply
      0
      • D Dr Walt Fair PE

        You didn't say what platform you are working on, but if it's WinForms, then you may need to Refresh() the control for the changes to be visible. If the program is busy doing other things, you may also need to use Application.DoEvents() to process any Windows messages that force the refreshing.

        CQ de W5ALT

        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

        M Offline
        M Offline
        MAW30
        wrote on last edited by
        #3

        Yes I am using WinForms. I tried the above, and it still doesn't work. So I tried a few other things and when I tried the following: this.numericUpDownAccount.ActiveControl.Refresh(); It said I needed to use the new command. So I tried both the following: NumericUpDown numericUpDownAccount = new NumericUpDown(); and NumericUpDown numericUpDownAccount = this.numericUpDownAccount; and it still doesn't work. Michael

        D L 2 Replies Last reply
        0
        • M MAW30

          Yes I am using WinForms. I tried the above, and it still doesn't work. So I tried a few other things and when I tried the following: this.numericUpDownAccount.ActiveControl.Refresh(); It said I needed to use the new command. So I tried both the following: NumericUpDown numericUpDownAccount = new NumericUpDown(); and NumericUpDown numericUpDownAccount = this.numericUpDownAccount; and it still doesn't work. Michael

          D Offline
          D Offline
          Dr Walt Fair PE
          wrote on last edited by
          #4

          OK, I hope I understand you correctly. If not, please correct me or perhaps someone else will jump in. If it said you need to use the new command, it seems you need to create the control. You'll also need to add it to Controls list of its container. Once you do that you should be able to refresh the container and it should display your added control, assuming the control, is implemented correctly. You can look at the designer code for any Form to see how the controls are created and added to the list of controls, etc.

          CQ de W5ALT

          Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

          M 1 Reply Last reply
          0
          • D Dr Walt Fair PE

            OK, I hope I understand you correctly. If not, please correct me or perhaps someone else will jump in. If it said you need to use the new command, it seems you need to create the control. You'll also need to add it to Controls list of its container. Once you do that you should be able to refresh the container and it should display your added control, assuming the control, is implemented correctly. You can look at the designer code for any Form to see how the controls are created and added to the list of controls, etc.

            CQ de W5ALT

            Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

            M Offline
            M Offline
            MAW30
            wrote on last edited by
            #5

            But, the control is all ready created I dragged it down from the tool box. I just don't think it knows what to focus on for whatever reason. Michael

            1 Reply Last reply
            0
            • M MAW30

              Yes I am using WinForms. I tried the above, and it still doesn't work. So I tried a few other things and when I tried the following: this.numericUpDownAccount.ActiveControl.Refresh(); It said I needed to use the new command. So I tried both the following: NumericUpDown numericUpDownAccount = new NumericUpDown(); and NumericUpDown numericUpDownAccount = this.numericUpDownAccount; and it still doesn't work. Michael

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              this.numericUpDownAccount.ActiveControl.Refresh();

              numericUpDownAccount is the name of your control and points thereto. ActiveControl is the current focused control, and might be null. That's why we have a manual. Paste the entire method if it still does not work.

              Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

              M 1 Reply Last reply
              0
              • L Lost User

                this.numericUpDownAccount.ActiveControl.Refresh();

                numericUpDownAccount is the name of your control and points thereto. ActiveControl is the current focused control, and might be null. That's why we have a manual. Paste the entire method if it still does not work.

                Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

                M Offline
                M Offline
                MAW30
                wrote on last edited by
                #7

                I Solved the probem, I realized after you wrote the above the control I am accessing is the original not the copy I added to my form, so I did the following in the form: this.ctrlMainControl1.numericUpDownAccount.Value = nAccountID; this changes he value of the copy of the control not the original control. Thanks, Michael

                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