Selections can be created programatically with the Platform API. This is done by querying data in a feature source, creating a feature reader that contains the features, then converting the feature reader to a selection (MgSelection object).
To create a feature reader, apply a selection filter to a feature class in the feature source. A selection filter can be a basic filter, a spatial filter, or a combination of the two. The filter is stored in an MgFeatureQueryOptions object.