Visual Studio Hacks [Electronic resources]

Andrew Lockhart

نسخه متنی -صفحه : 172/ 92
نمايش فراداده

Hack 59. Get Help

Visual Studio''s help is of the F1 variety, but it also goes way beyond that. Learn how to get the most from Visual Studio''s built-in help.

Visual Studio includes a rich help experience, one that improves even more with the release of Visual Studio 2005. Knowing how to best use help can help make you a more efficient and faster developer.

7.2.1. Press F1 for Help

Like most applications, the main key to remember with the Visual Studio help system is F1. Visual Studio''s F1 is a little smarter than most applications though. Instead of just opening a generic help window, F1 pays attention to the context in which you are asking for help. For instance, if you select the Solution Explorer window and press F1, Visual Studio will display a help document about how to use the Solution Explorer.

While you are developing, you can select a piece of code and press F1. This will call up the documentation for whatever you happened to highlight. When you do this, Visual Studio is performing an index search for the item that you highlighted. If you have no code highlighted, it will provide help for the best match based on context. For example, if your cursor is on the .Clone method of a String variable, F1 will take you to the help page for the String.Clone method. If there is more than one result for the item you highlighted, you will see the index search dialog shown in Figure 7-1.

Figure 7-1. Index search dialog

In this example, I highlighted AssemblyConfiguration in my code and pressed F1. If I highlighted the term int and pressed F1, it would take me right to the documentation about integers instead of showing me the index screen. You can also access the Index search screen directly by going to Help Index.

7.2.2. Dynamic Help

Dynamic Help can be both a curse and a blessing. Elsewhere in the book, we have recommended that you disable this feature to improve the performance of the IDE [Hack #44] . Dynamic Help can be a very useful tool; you just need to weigh the performance versus the helpfulness of this tool for you. If you find Dynamic Help to be useful, then its small performance hit will well be worth the benefit.

What Dynamic Help does is display a window with help topics that might be helpful based on the action you are currently performing. Figure 7-2 shows the Dynamic Help window.

Figure 7-2. Dynamic Help window

In this example, I happen to have a code file from the XMLLib Namespace open so it shows the documentation for that namespace under Help. You can also use Dynamic Help much like F1. If you simply select the word int in your code file without pressing any keys, you will then see the window shown in Figure 7-3.

Figure 7-3. Dynamic Help picking up on what you''ve highlighted

Notice how Dynamic Help picked up on the fact that you highlighted the word int and now displays multiple help documents pertaining to the int type. Dynamic Help can be a great tool for a learning developertargeted help topics will always be at your fingertips whatever you happen to be working on.

7.2.3. Contents and Search

If normal F1 and Dynamic Help are not providing the information you need, it is time to turn to either the Contents window or the Search window. Both of these portions of help require more work on your part to find what you need. The Contents window is a simple table of contents for all the .NET help installed on your machine and is shown in Figure 7-4.

Figure 7-4. Help Contents window

Using the Contents window, you can browse through all the help collections installed on your machine. A help collection is a group of help documents pertaining to a particular topic. In Figure 7-4, each of the top-level nodes is a separate help collectionyou can tell from this that I have certain tools like ReSharper and Visual Studio .NET Help Integration Kit installed.

If you would rather not browse through this tree structure, you can use the Search window, which will perform a full-text search on help using keywords that you provide. The Search window can be seen in Figure 7-5.

Figure 7-5. Help Search window

After clicking Search, you will see the results screen shown in Figure 7-6.

Figure 7-6. Search Results window

While Visual Studio''s search is somewhat good, you may find turning to your favorite online search engine more helpful. However, read on for some improvements in Visual Studio 2005 that extend the help system and even include online sources.

7.2.4. Visual Studio 2005 Help System

Visual Studio 2005 includes all the help features you have become accustomed to in prior version of Visual Studio, but also includes a number of new helpful features.

7.2.4.1 How do I?

The first new feature in Visual Studio 2005 help is the How Do I tab in the new help window. In Figure 7-7, you can see this tab inside the new help window.

Figure 7-7. How Do I tab

The How Do I tab includes links to a number of tutorials on various tasks you might want to perform while in Visual Studio. From Figure 7-7, you can also see the new help window, which gives you a central window from which to work with all the different parts of help. This window also includes new features like Help Favorites, which allow you to bookmark help topics or search results and access them from a single window.

7.2.5. Online Search

One of the best new features in Visual Studio 2005 is the ability to search online resources directly from Visual Studio. Using this new online search feature, you can search not only MSDN online but also any of the sites that are part of the CodeWise community of sites. The first time you use help in Visual Studio 2005, you''ll be asked to choose how you want to use online help. The default is to use local help as the primary source, but to also consult online help when you are connected to the Internet. You will need to agree to the online help privacy policy if you choose to use it.

The CodeWise community is a collection of Microsoft endorsed technical sites. Chances are you have run across some of these sites as they include favorites like CodeProject, DotNetJunkies, and the ASPAlliance. For more information, please refer to http://www.gotdotnet.com/content/codewise.

By default, online search will be enabled and is integrated into the same help that appears when you press F1. If you select "bool" in your document and press F1, you will see the screen shown in Figure 7-8.

Figure 7-8. Online search

This is just the beginning of what you can do though. If you click on the Search button at the top, you can enter any term you want and search MSDN and all the CodeWise sites and MSDN Online as well. This search is shown in Figure 7-9.

Figure 7-9. Online search goes beyond MSDN

In the results pane you will see three different sections of results: MSDN Online results, Local Help results, and Code Wise Community results. You can click on any of these results, and they will be loaded into the list on the left (replacing MSDN Online results), where you can then scroll through the results and find what you are looking for.

The new help features in Visual Studio 2005 make it even easier to find the information you are looking for.

7.2.6. Use Safari from Help

Visual Studio 2005 includes the ability to extend the help system and add additional search locations to the help system. O''Reilly has done a wonderful thing and added the ability to search through the entire Safari online library when you search help.

Safari is a huge electronic reference library that includes not only O''Reilly books but also books from more than a dozen other publishers. You can search through the text of books and then view the contents of the books, all online.

To install this new search location, you simply need to go to VS2005 Help Tool along the top menu. When you click this link, you will be able to download a simple .reg file. When you run the .reg file, it will add registry settings that add a search function for the Safari online library. The next time you search help, Safari will appear just like MSDN Online or the CodeWise Community sites. Search results from the Safari library can be seen in Figure 7-10.

Figure 7-10. Safari search

You can look forward to a number of these search enhancements being added as we get closer to the final version of Visual Studio 2005.