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. VS2005, variables with values of form elements not updating when interacted with by user.

VS2005, variables with values of form elements not updating when interacted with by user.

Scheduled Pinned Locked Moved C#
helpdatabasecom
11 Posts 2 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 Mihai Pruna

    Basically, if I input a text and I query the variable Texbox.Text, for instance, it still stays empty or shows the initial value of the text field. Same with checkboxes, etc. I was able to fix this issue before, but I can't for my life remember how. I tried form refreshes and updates and reloads. Thanks!

    Codes for Scientists and Engineers

    D Offline
    D Offline
    Deresen
    wrote on last edited by
    #2

    Can you maybe show some code where you read the value? Because if you also make a button and add an onclick event on this one and put a breakpoint there, you can read out the value of the textbox in the immediate window. Should work.

    M 1 Reply Last reply
    0
    • D Deresen

      Can you maybe show some code where you read the value? Because if you also make a button and add an onclick event on this one and put a breakpoint there, you can read out the value of the textbox in the immediate window. Should work.

      M Offline
      M Offline
      Mihai Pruna
      wrote on last edited by
      #3

      the problem is, I am developing plugins for an external program. I cannot debug because the plugins (DLLs) are accessed by buttons on the program's graphical interface rather than being mere external commands or macros. Thus I cannot start the application remotely while debugging the code. I have to put message boxes to show me any variables in the code....and those were the values I found. I used a form reload/refresh command in the subroutine of the event of clicking on a checkbox and that didn't actually update the content of the 'checked' variable.

      Codes for Scientists and Engineers

      D 1 Reply Last reply
      0
      • M Mihai Pruna

        the problem is, I am developing plugins for an external program. I cannot debug because the plugins (DLLs) are accessed by buttons on the program's graphical interface rather than being mere external commands or macros. Thus I cannot start the application remotely while debugging the code. I have to put message boxes to show me any variables in the code....and those were the values I found. I used a form reload/refresh command in the subroutine of the event of clicking on a checkbox and that didn't actually update the content of the 'checked' variable.

        Codes for Scientists and Engineers

        D Offline
        D Offline
        Deresen
        wrote on last edited by
        #4

        If you reload your form, the data will be set to default. Maybe try using Threads and update the textboxes/ labels every 100 ms. You can also still try the button and update when you click on the button.

        M 1 Reply Last reply
        0
        • D Deresen

          If you reload your form, the data will be set to default. Maybe try using Threads and update the textboxes/ labels every 100 ms. You can also still try the button and update when you click on the button.

          M Offline
          M Offline
          Mihai Pruna
          wrote on last edited by
          #5

          what's the difference between doing a button and just dumping code into the Checkbox clicked event?

          Codes for Scientists and Engineers

          D 1 Reply Last reply
          0
          • M Mihai Pruna

            what's the difference between doing a button and just dumping code into the Checkbox clicked event?

            Codes for Scientists and Engineers

            D Offline
            D Offline
            Deresen
            wrote on last edited by
            #6

            It always works for me. But there is no difference, I didn't understand you already used a userevent (checkbox clicked). But have you tried not to reload the form, but only reload the data?

            M 1 Reply Last reply
            0
            • D Deresen

              It always works for me. But there is no difference, I didn't understand you already used a userevent (checkbox clicked). But have you tried not to reload the form, but only reload the data?

              M Offline
              M Offline
              Mihai Pruna
              wrote on last edited by
              #7

              using something like checkbox.update(); ?

              Codes for Scientists and Engineers

              D 1 Reply Last reply
              0
              • M Mihai Pruna

                using something like checkbox.update(); ?

                Codes for Scientists and Engineers

                D Offline
                D Offline
                Deresen
                wrote on last edited by
                #8

                No, You've got some form, this is your outputscreen, the way you debug, right? So let's say you have one label named outputLabel and one checkbox. When you initialize, you will probably do something like this:

                public Form()
                {
                InitializeComponents();
                outputLabel.Text = getDataFromDatabase();
                }

                and then something happens and the values changes, but you won't see those values, because you didn't update your form. So in your case you will do something like this:

                public void checkBox_Clicked(object sender, EventArgs e)
                {
                Form.Reload();
                }

                but in stead of this, you have to only refresh the values in the textboxes/labels. Something like this:

                public void checkBox_Clicked(object sender, EventArgs e)
                {
                outputLabel.Text = getDataFromDatabase();
                }

                that's all. If it is something else, you should place some code of the eventhandling.

                M 1 Reply Last reply
                0
                • D Deresen

                  No, You've got some form, this is your outputscreen, the way you debug, right? So let's say you have one label named outputLabel and one checkbox. When you initialize, you will probably do something like this:

                  public Form()
                  {
                  InitializeComponents();
                  outputLabel.Text = getDataFromDatabase();
                  }

                  and then something happens and the values changes, but you won't see those values, because you didn't update your form. So in your case you will do something like this:

                  public void checkBox_Clicked(object sender, EventArgs e)
                  {
                  Form.Reload();
                  }

                  but in stead of this, you have to only refresh the values in the textboxes/labels. Something like this:

                  public void checkBox_Clicked(object sender, EventArgs e)
                  {
                  outputLabel.Text = getDataFromDatabase();
                  }

                  that's all. If it is something else, you should place some code of the eventhandling.

                  M Offline
                  M Offline
                  Mihai Pruna
                  wrote on last edited by
                  #9

                  thanks i will try that.

                  Codes for Scientists and Engineers

                  M 1 Reply Last reply
                  0
                  • M Mihai Pruna

                    thanks i will try that.

                    Codes for Scientists and Engineers

                    M Offline
                    M Offline
                    Mihai Pruna
                    wrote on last edited by
                    #10

                    well I couldn't find a command called getfromdatabase. Did you mean I would have to create my own subroutine and storage variable? I did that for a checkbox, so now when the checkbox is changed a static boolean variable is swithced. That works for checkboxes, but implementing it for textboxes for instance might prove cumbersome.

                    Codes for Scientists and Engineers

                    D 1 Reply Last reply
                    0
                    • M Mihai Pruna

                      well I couldn't find a command called getfromdatabase. Did you mean I would have to create my own subroutine and storage variable? I did that for a checkbox, so now when the checkbox is changed a static boolean variable is swithced. That works for checkboxes, but implementing it for textboxes for instance might prove cumbersome.

                      Codes for Scientists and Engineers

                      D Offline
                      D Offline
                      Deresen
                      wrote on last edited by
                      #11

                      No, all I did was asuming. I asumed you would get data from a 'place' and that 'place' would be getFromDatabase(). But to recap, to clear that I understand your problem well: You have a form which you create and can own You have a process running on a computer This process will change some stuff and you want to get those on your form for debugging. To refresh, you are using a checkbox with an OnChanged event? But when you click on the checkbox, nothing happens. Is this correct? If it is, please send the code which is inside the OnChanged event. Then I can maybe see the problem. If there is no code inside this event, then I would suggest you to call a function which will place the values you would like to see/debug, on your screen.

                      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