Using selection properties, Selection highlighting and exporting, Selectionchangedevent – Pitney Bowes MapXtreme User Manual

Page 203

Advertising
background image

Chapter 9: Working with Core MapXtreme Classes

Selection Class

MapXtreme v7.1

210

Developer Guide

Each Selection must have a name and unique alias. By default, map selection tools modify the
Selection when used. Each tool can be set to use any particular Selection.

A selection in MapXtreme is not a copy; it is a reference to an IResultSetFeatureCollection for a
given table in a Selection. If you attempt to modify a Selection after you have closed the table that
you are working with, the reference to the IResultSetFeatureCollection will be invalid, causing an
exception.

Features are selected using tools or through search methods. For a discussion of the different
selection tools that you can use when building a Windows Forms application, see

Chapter 7:

Desktop Applications, Controls, Dialogs, and Tools

. For selection Web controls and tools, see

Chapter 5: Web Applications, Controls, and Tools

.

Features can also be selected through search methods from the MapInfo.Data.Catalog class which
returns IResultSetFeatureCollection collections. A Selection object can be passed into a search,
which can be used to populate or change a Selection.

Features can also be selected via the ExecuteFeatureCollection method from the Data.MICommand
class. In this case, you would execute SQL commands against the MapInfo Data Provider.

For more information on features, tables, the Catalog, and the MICommand, see

Chapter 8:

Working with Data

.

Using Selection Properties

The properties of the Selection class are used to set the (required) name and alias, set a selection to
be Visible or Editable, or to get the selection’s Style. To determine whether a Selection displays its
highlighting to indicate it is selected or is available for editing, use the Visible or Editable property,
respectively.

If the Editable property is set to true, the table that you are working with must also be editable.

The Style property indicates the Selection's style and returns a reference to the Selection's
composite style. When you change a Style property, the Selection object is notified of the change. It
will take affect the next time the Selection object is drawn. Styles are discussed in

Chapter 15:

Stylizing Your Maps

.

Selection Highlighting and Exporting

Selections are typically drawn on the map with special highlighting, to distinguish these features
from surrounding non-selected features. The highlighting is controlled by the
Mapping.FeatureViewer.DrawSelections property. When this property is set to true, they are drawn
with selection highlighting, provided they are drawn on a visible layer.

Similarly, the MapExport.ExportSelection property, can be used to control whether the selections are
drawn into the exported image.

SelectionChangedEvent

A delegate method is attached to the SelectionChangedEvent in order to receive notification that this
selection has changed. For example, if a record is added, the SelectionChangedEvent is fired.

Advertising