Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / XML

Visual Studio Tips - Using Data Tips

4.63/5 (6 votes)
1 Apr 2019CPOL2 min read 8.4K  
Few tricks about data tips, the Visual Studio feature that allows you to hover over a variable and see its value while debugging

Data tips, the Visual Studio feature that allows you to hover over a variable and see its value while debugging, can be super useful. Here are a few tricks that you may not know about them.

Have you ever been looking in the DataTips, then need to look at the code behind them? Great news, you can. Just press and hold Ctrl key, the DataTips become transparent until you release the Ctrl key. This is particularly useful when you’ve drilled down a bit in the DataTip or you’re trying to compare.

Image 1

Another thing you can do is either pin the DataTips. This persists the DataTip so you can navigate to other code, restart debugging or even restart Visual Studio and still have the DataTip be there when you break in that block the next time. Once you’ve pinned a DataTip, you can move the data tip around by clicking and dragging, you can remove it by clicking the x, or you can float the DataTip by clicking the pin icon. This allows you to view that DataTip while you scroll the code or view another file.

Image 2

Once you’ve pinned a DataTip, you can add expressions to that DataTip by right-clicking on the DataTip and choosing “Add Expression”. This can let you pin something more useful than what might normally display for an object. In this case, the DebuggerDisplay shows LastName, FirstName, but we can add an expression to display the Person object as FirstName LastName. This is really handy for when you can’t change the DebuggerDisplay of an object.

Image 3

The other interesting feature of DataTips is that you can add comments to them.

Image 4

But what good are comments if you can’t share them? Well, you can export your DataTips to an XML file and either share them or check them in with your source. You could have a set of DataTips that you load up whenever you’re facing a common debugging scenario.

Image 5

You might also notice there are options in there to “Clear All DataTips”, and “Clear All DataTips from [CurrentFileName]”.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)