[Visual Basic 6.0]The following code creates a selection set using SelectDisplayTable, then reports the number of selected features. It is necessary to create a scratch workspace to use for the selection. This code only creates a selection set; it does not show the selection on the display. To see how to show the selection on the display, refer to IFeatureSelection.
Sub DisplayTableSelect() Dim pDoc As IMxDocument Dim pMap As IMap Dim pDisplayTable As IDisplayTable Dim pScratchWorkspace As IWorkspace Dim pScratchWorkspaceFact As IScratchWorkspaceFactory Dim pQF As IQueryFilter Dim pSelSet As ISelectionSet Set pDoc = Application.Document Set pMap = pDoc.FocusMap Set pDisplayTable = pMap.Layer(0) ' create scratch worksapce to use for the selection Set pScratchWorkspaceFact = New ScratchWorkspaceFactory Set pScratchWorkspace = pScratchWorkspaceFact.DefaultScratchWorkspace ' create the query filter Set pQF = New QueryFilter pQF.WhereClause = "CAPITAL = 'Y'" ' create the selection set and report using a message box Set pSelSet = pDisplayTable.SelectDisplayTable(pQF, esriSelectionTypeIDSet, esriSelectionOptionNormal, pScratchWorkspace) MsgBox pSelSet.Count End Sub
[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button
in the upper-left corner of the page.