This document is archived and information here might be outdated.  Recommended version.


Statements option for the ArcGIS Snippet Editor (ArcObjects .NET 10.4 SDK)

Statements option for the ArcGIS Snippet Editor


Summary
The ArcGIS Snippet Editor uses a series of dialog boxes to create ArcGIS snippets. Use the Statements - ArcGIS Snippet Editor dialog box to replace values for variables encased in dollar signs ($) when you insert ArcGIS snippets into the code editor.

In this topic


About the ArcGIS Snippet Editor statements option

The Statements - ArcGIS Snippet Editor is the fifth (and final) in a series of dialog boxes that lets you create or edit an ArcGIS snippet. Use this dialog box to specify replacement values, object types, and help strings for variables encased in dollar signs ($) when you insert ArcGIS snippets into the code editor. See the following screen shot:
You will not see the Statements - ArcGIS Snippet Editor dialog box if you selected the "function-sub-method" or "other" as the snippet type in the second dialog box, Title, Long Description, Type, Directory - ArcGIS Snippet Editor. For details, see Title, long description, type, and directory options for the ArcGIS Snippet Editor.

Statements snippet types

The statements snippet type are code fragments that act as templates for you to modify. Usually, code from statements snippets will not compile unless you make modifications. Unless otherwise directed, insert statements snippets in an existing method, function, or sub in your class. Typically, they do not perform a complete programming task.
The majority of snippets provided by Microsoft with Visual Studio are the statements type (that is, code fragments). Microsoft does not make a distinction between different snippet types (this is a term specific to ArcGIS snippets).

Create statements for ArcGIS snippets

The following code example shows a statements snippet type:
[VB.NET]
System.Windows.Forms.MessageBox.Show("Hello World")
[C#]
System.Windows.Forms.MessageBox.Show("Hello World");
Statements snippets can require modification to be useful. When you want to substitute your value, the section of code that needs modifying is highlighted with a green box (when using the Microsoft snippet insertion method).
Hovering over the green highlighted section of the statements snippet causes a ToolTip to appear directing you to change the value to meet your coding requirements. The ToolTip indicates the value and provides an example that you can use.
See the following screen shot that shows the standard Microsoft snippet insertion method that is based on an ArcGIS snippet statements type:
The ArcGIS Snippet Finder does not have the ability to show ToolTips and change the substitution value like the standard Microsoft snippet insertion method. This functionality will be considered for a future release of the ArcGIS Snippet Finder.
The ArcGIS Snippet Editor dialog boxes can create statements snippet types with substitution values. To do this, encase the substitution value within dollar signs ($) in the text box on the Source code - ArcGIS Snippet Editor dialog box. For details, see Source code option for the ArcGIS Snippet Editor.
Using the preceding code example as the desired end result of a statements type of snippet, the goal is to allow developers who use the standard Microsoft snippet insertion method the ability to replace the "Hello World" string with another value.
The following code example shows what to type in the text box of the Source code - ArcGIS Snippet Editor to accomplish this:
[VB.NET]
System.Windows.Forms.MessageBox.Show($GREETING$)
[C#]
System.Windows.Forms.MessageBox.Show($GREETING $);
The following screen shot shows the Statements - ArcGIS Snippet Editor with a replacement value, object type, and Help string for the substitution ID value $GREETING$:
To edit values shown in the preceding screen shot, click inside a cell.
You can also use the dollar sign ($) substitution values for types rather than values. See the following code example:
[VB.NET]
m_ActiveView.Refresh()
[C#]
m_ActiveView.Refresh();
The type, m_ActiveView, is an ESRI.ArcGIS.Carto.IActiveView interface. Use the $ substitution values by modifying the following code example:
[VB.NET]
$ACTIVEVIEW$.Refresh()
[C#]
$ACTIVEVIEW $.Refresh();
Specify values in the Statements - ArcGIS Snippet Editor similar to the following screen shot:
The following screen shot shows the results after you have inserted this ArcGIS snippet using the standard Microsoft snippet insertion method:
 

ArcGIS snippets statements type without substitution values

You can create an ArcGIS snippet statements type that does not contain dollar sign ($) substitution values.
Your code will be added to the code editor, whether you use the ArcGIS Snippet Finder or the standard Microsoft snippet insertion method. However, the Statements - ArcGIS Snippet Editor dialog box appears without records in the table to change substitution values. See the following screen shot:


See Also:

ArcGIS Snippet Editor
Overview of the ArcGIS Snippet Editor Manager
Customization options for the ArcGIS Snippet Editor Manager
Title, long description, type, and directory options for the ArcGIS Snippet Editor
Source code option for the ArcGIS Snippet Editor
References option for the ArcGIS Snippet Editor
Extensions, products, and versions options for the ArcGIS Snippet Editor
Snippets for ArcGIS .NET developers
ArcGIS Snippet Finder




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Additional Requirements
  • Use display settings of 96 dots per inch (dpi) when using the ArcGIS Snippet Finder and ArcGIS Snippet Editor.

Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
Engine Developer Kit Engine