Object Element (IntelliSense Code Snippets)

Defines the objects of the code snippet that you can edit.


<Object Editable="true/false">
    <ID>... </ID>
    <Type>... </Type>
    <ToolTip>... </ToolTip>
    <Default>... </Default>
    <Function>... </Function>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.





Optional Boolean attribute.

Specifies whether or not the object can be edited after the code snippet is inserted. The default value of this attribute is true.

Child Elements




Required element.

Specifies the object's default value when the code snippet is inserted. There must be exactly one Default element in a Object element.


Optional element.

Specifies a function to execute when the object receives focus in Visual Studio. There may be zero or one Function elements in a Object element.


Required element.

Specifies a unique identifier for the object. There must be exactly one ID element in an Object element.


Optional element.

Describes the expected value and usage of the object. There may be zero or one Tooltip elements in an Object element.


Required element.

Specifies the type of the object. There must be exactly one Type element in an Object element.

Parent Elements




Contains the literals and objects that make up the parts of a code snippet that you can edit.


The Object element is used to identify an item that is required by the code snippet but is likely to be defined outside of the snippet itself. For example, Windows Forms controls, ASP.NET controls, object instances, and type instances should be declared as objects. Object declarations require that a type be specified, which is done with the Type element.


The following code example shows how to declare a SqlConnection object with an ID element value of Connection. The object is referenced in the Code element by using the default delimiter. In this example, the object is referenced with $Connection$.

Literals and objects cannot contain an ID element with a value of end. The value $end$ is reserved, and is used to mark the location to place the cursor after the code snippet is inserted.

<CodeSnippets xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
            <Title>Create a data adapter</Title>
            <Description>Creates a SqlDataAdapter object.</Description>
            <Author>Microsoft Corporation</Author>
                    <ToolTip>Replace with a SQL connection string.</ToolTip>
                    <Default>"SQL connection string"</Default>
                    <ToolTip>Replace with a connection object in your application.</ToolTip>
            <Code Language="CSharp">
                    daCustomers = new SqlClient.SqlDataAdapter();
                    selectCommand = new SqlClient.SqlCommand($SQL$);
                    daCustomers.SelectCommand = selectCommand;
                    daCustomers.SelectCommand.Connection = $Connection$;

See Also


Code Snippets Schema Reference

Other Resources

Code Snippets