Visual Studio 2008 Pro: Ok! from the Customize section I added the toolbar commands for Watch,QuickWatch,...to the Debug menu but I want to carefully watch one variable. How do we add it to the Watch? I highlight it and try to add it but it is disabled. I want to be able to first adding some variables of interest to the watch and then start debugging the program.Answer1:
You will be able to add, view and remove variables from the Watch Mode when you are running under the debugger and execution is paused. The easiest way to get into such a state:<ol><li>Open your project in Visual Studio</li> <li>Set a breakpoint in the code within the scope of a variable you'd like to watch. Make sure that the code branch you're breaking on will be executed.</li> <li>Hit F5 or go to Debug > Start Debugging</li> <li>When the breakpoint is hit, add your variable to the watch window in any of the following ways: <ul><li>Right click on the variable in code, and select "Add Watch"</li> <li>Right click on the variable in the "Locals" windows, and select "Add Watch"</li> <li>Type the variable name into a new row in the Watch pane itself.</li> </ul></li> </ol>
Afterwards, you should see the variable name and value in the watch pane. The value will be updated as you step through the code and any time you pause execution or hit a breakpoint.Answer2:
You need to be in debugging in order to add variables to the Watch Window.
When debugging, you can just right click a variable and choose to add it to the watch.