mapx模糊查询

Dim templayer As Layer, tempFeatures As New MapXLib.Features
Dim TempDataset As MapXLib.Dataset, TempFeature As MapXLib.Feature, TempField As MapXLib.Field
Dim NodX As Node, NodY As Node, NodZ As Node
If Trim(Text1.Text) = "" Then
  MsgBox "请输入要查找内容"
  Text1.SetFocus
  Exit Sub
End If
TreeView2.Nodes.Clear
    For Each templayer In Map1.Layers
      If templayer.Selectable = True Then
        Set TempDataset = Map1.DataSets.Add(miDataSetLayer, templayer)
        Set tempFeatures = Map1.Layers.Item(templayer).Search(templayer.KeyField + " like ""%" + Trim(Text1.Text) + "%""")
          If tempFeatures.Count > 0 Then
            Set NodX = TreeView2.Nodes.Add(, tvwChild, templayer.Name, templayer.Name)
            NodX.EnsureVisible
              For Each TempFeature In tempFeatures
              Set NodY = TreeView2.Nodes.Add(NodX, tvwChild, templayer.Name + "|||" + TempFeature.FeatureKey, TempFeature.Name)
              NodY.EnsureVisible
              Next
          End If
      End If
    Next

你可能感兴趣的:(each,layer)