The Watch Window: Watching and Changing Values
Keyboard: SHIFT + F9 (QuickWatch)
Menu: Debug -> QuickWatch; [RIGHT CLICK] -> Add Watch
Command: Debug.QuickWatch; Debug.AddWatch
Versions: 2008,2010
Published: 10/8/2010
Code: vstipTool0104
By definition, a Watch is exactly what it sounds like: watching something. There are two kinds of watches you can do: (1) QuickWatch and (2) Add Watch. Let's take a closer look.
Just a Watch
First, we need to define what you can watch. Essentially, you can watch any valid expression. Here are some examples of valid watches:
Watch Window
The easiest way to get a Watch window is to press CTRL + ALT + W,1 or go to Debug -> Windows -> Watch -> Watch 1. You can have up to four Watch windows so you can organize your watches into groups if you desire but most people start with Watch 1 typically:
Putting In A Watch
Just Type It In
The easiest way to put in most watches is just to type in the variable or expression you want to watch:
QuickWatch (SHIFT + F9)
Despite the name this is actually the longest way to set a watch. When you press SHIFT + F9 or go to Debug -> QuickWatch this is the dialog you get:
You can put in any expression in the Expression area and then click the Reevaluate button to see the value appear in the Value area. If you are happy with what you see and want to add a watch to the watch window then you just click the Add Watch button.
Add Watch
This is actually a pretty quick watch you can set. Just RIGHT CLICK a variable or selected expression and instantly have it added to Watch 1:
Changing Values
With any watch you can change the value to suit your needs by just selecting the value to change:
Then type in a new value and press ENTER:
Notice how the value turns red to indicate it has changed? Very cool stuff.
Comments
Anonymous
October 07, 2010
The (very) annoying part of the QuickWatch window is that it is application modal.Anonymous
October 08, 2010
"With any watch you can change the value..." Might want to clarify that; pretty sure you can change the value of any watched variable, but not an expression. ie, you can change the value of 'c', or 'd', but you can't change the value of 'c+d'.