Browsing the Object Browser

The Visual Studio IDE has an Object Browser similar to the one you find in the VBE. You can use the Object Browser to view all the methods, properties, and events of a particular object, as shown in Figure 2.18.

For example, you can use the Object Browser to learn about all the extended objects in VSTO. The Object Browser displays all available

...•"'Object Browser ["' 5ampleWorkbook.xls [ 5tart Page

Browse: All Components

JJ§ ActionClickEventHandler

S % ActionEventArgs

S % BeforeAddDataBoundRowEventArgs_|

^ BeforeAddDataBoundRowEventHandl BeforeCaptionShowEventHandler

c#> ChangeReason

¡^p ChangeType E Chart S % ChartSheet 1+1 ControlCollection El ControlCollectionEnumerator EJ-^f ErrorAddDataBoundRowEventArgs

ErrorAddDataBoundRowEventHandler

S-% ExcelLocale 1033At tribute El ExcelLocale 1033Proxy

=p FailureReason

¡^P FormatSettings "O IListObjectDesignSupport El •% ListObject r^l ListObjectChangeHandler El % ListObjectNotDataBoundException

¡sp ListRanges

El ^ OriginalDataRestoredEventArgs li__^..„.^-.p-^-j

5ubscribeTo(5tringj [Microsof t.Off ice, Interop. Excel, Xl5ubscribeToFormat]) As Object Subtotal(Integer, Microsoft.Office.Interop.Excel.XIConsolidationFunction, Object, [Object], [Objec • ^ SummaryO As Object

Table([Object]j [Object]) As Object Tag() As Object fg}1 Text() As Object

TextToColumnsitObject], [Microsoft. Office. Interop. Excel. XlTextParsingType], [Microsoft.Off ice, In [SP Top() As Object To5tring() As String UngroupQ As Object ^ UnMerge() ■ ^ Use5tandardHeight() As Object fg* UseStandardWidth() As Object •if ValidationQ As Microsoft.Office.Interop.Excel.Validation

Value2() As Object f^f1 VerticalAlignment() As Object ••]|f, WidthO As Object

■j^ Worksheet) As Microsoft.Office.Interop.Excel.Worksheet •f^f WrapTextQ As Object f XPathO As Microsoft. Office. Interop.Excel. XPath

Public Property Value () As Object

Member of: Microsoft.Office,Tools.Excel.NamedRanne Summary:

Gets or sets the value of the Microsoft.Office.Tools.Excel.NamedRange control. Return Values:

The value of the Microsoft.Office.Tools.Excel,NamedRange control.

Figure 2.18. The Value property of the NamedRange displayed in the Object Browser objects in your project in the Objects pane on the left. You can expand each object to display additional information, such as its properties, methods, events, and constants. This information appears in the Members pane on the upper-right side.

To open the Object Browser, click the View menu and then click Object Browser. If you want to change the browsing scope of the objects you're viewing, you can use the Browse drop-down menu. For example, if you click the drop-down box and select My Solution, only the namespaces pertinent to your current solution—including all components referenced in your solution—will be visible in the Object Browser. You can also search for objects in the Object Browser by using the Search menu, or you can change the view of the objects, such as displaying only namespaces, base types, derived types, or public members.

When you select an object in the Objects pane, Visual Studio displays its members in the Member pane and displays information about the object in the Description pane in the lower-right portion of the browser. Let's say that you want to see all the properties, methods, and events of a NamedRange. You select the NamedRange object under the Microsoft.Office.Tools.Excel namespace, and all its members are displayed in the Members pane. When you select a particular member, such as Value, the Description pane displays additional information, including a summary and a return value for the property, as shown in Figure 2.l8. You can get additional information about the types or members by selecting an object and pressing Fl. This action opens a document in Help that pertains to the object under your cursor.

As you browse through the objects in your solution, notice that there are two namespaces listed for Word, for Excel, and for Outlook. In a Word solution, you'll find the Microsoft.Office.Jnterop.Word namespace, which represents the primary interop assembly for Word. There's also a Microsoft.Office.Toois.Word namespace, which contains all the VSTO enhanced objects.

In Excel, you'll find a Microsoft.OfficeJnterop.Excel namespace and a corresponding Microsoft.Office.Tools.Excel namespace. Similarly, in Outlook, there is a Microsoft.OfficeJnterop.Outlook namespace and a corresponding Microsoft.Office.Toois.Outlook namespace.

It's important to note this, because when you want to look up a particular member of an object, you'll want to make sure that you are viewing the member in the appropriate namespace. For example, the members of a Bookmark in Microsoft.Office.Toois.Word are different from the members of a Bookmark in Microsoft.OfficeJnterop.Word. You will learn more about these differences in Chapter 6, Customizing Word with VSTO.

0 0

Post a comment