VS2005, variables with values of form elements not updating when interacted with by user.
-
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!
-
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.
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.
-
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.
-
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.
what's the difference between doing a button and just dumping code into the Checkbox clicked event?
-
what's the difference between doing a button and just dumping code into the Checkbox clicked event?
-
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?
using something like checkbox.update(); ?
-
using something like checkbox.update(); ?
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.
-
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.
thanks i will try that.
-
thanks i will try that.
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.
-
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.
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.