Query Features


Purpose
It's a simple example of a button that allows you to digitize a polygon on the map, and then uses that polygon to query the features in the selected feature layer. The results of the query are displayed using a DataGridView on a form by binding the grid to the query results using a TableBindingAdapter.



Note that the declaration of this button in the AddIns.xml includes a condition which ensures the button is only enabled when a feature layer is selected in the contents window.



The aspects of the API that this particular sample illustrates are:

    • A button add-in
    • The use of a condition when declaring a button
    • Tracking geometries on the map
    • Querying a feature layer's table using a geometry
    • Binding the results of a query (a RowCollection) to a .Net control using a TableBindingAdapter

How to use

See Using the samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

Query Features
  1. Open and build the solution in Visual Studio.
  2. Open ArcGIS Explorer, and open a map that has a feature layer. Alternately, add a feature layer to the map.
  3. Select the Add-Ins tab from the ArcGIS Explorer ribbon.
  4. Select the desired feature layer in the Contents window.
  5. Click the Query Features button. Note: The Query Features button is unavailable until you select a feature layer in the Contents window.
  6. Digitize a polygon on the map to select the desired features. Double-click to finish the polygon.
  7. A table appears displaying the data for the selected features.


Download the files for all languages
QueryFeaturesButton.cs Code to digitize the polygon and query the features
Download the C# files
QueryFeaturesButton.vb Code to digitize the polygon and query the features
Download the VB.NET files