[VB.NET]VB.NET+MAPX查询问题

前端之家收集整理的这篇文章主要介绍了[VB.NET]VB.NET+MAPX查询问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
VB.NET+MAPX查询问题 Dim FindObj As MapXLib.Find Dim FoundFeature As MapXLib.FindFeature ''从要查询的RTU图层生成Find对象,并为这个对象设置要查询的FindDataSet、FindField属性 FindObj = AxMap1.Layers.Item(1).Find FindObj.FindDataset = AxMap1.DataSets(Me.ComboBox2.Text & "dataset ") ''( "RTU节点 " & " dataset ") FindObj.FindField = FindObj.FindDataset.Fields(Me.ComboBox2.Text) ''( "RTUName ") FoundFeature = FindObj.Search(ComboBox1.Text) Me.Hide() '' 关掉AutoRedraw是因为CenterX(Y)的改变就要刷新图层,AutoRedraw打开的话会造成二次刷新 AxMap1.AutoRedraw = False Me.Show() -------------------------------------------- 编译通过后 Me.ComboBox2.Text 中输入图层名 ComboBox1.Text中输入内容 “FindObj.FindDataset = AxMap1.DataSets(Me.ComboBox2.Text & "dataset ")”这行总是提示 “No object was found using the index you specified.” 请问是怎么了? __________________________________________________________________________ 没人知道吗? __________________________________________________________________________ 谁知道告诉小弟啊 __________________________________________________________________________ AxMap1.DataSets之前add过么? 你的代码有问题,觉得你至少也要写成axmap1.datasets.item()什么的吧? __________________________________________________________________________ 所有代码是: Dim lyR As MapXLib.Layer Dim findobj As MapXLib.Find Dim findStr As String Dim i As Short Dim fdat As MapXLib.FindFeature Dim layerds As MapXLib.Dataset Dim fid As MapXLib.Field On Error Resume Next TreeView1.Nodes.Clear() Dim result As Integer ''数据绑定 For Each lyR In AxMap1.Layers AxMap1.DataSets.Add(MapXLib.DatasetTypeConstants.miDataSetLayer,lyR,lyR.Name) Next lyR findStr = TextBox1.Text.Trim ''输入查询目标 " Dim X As MapXLib.Field ''Field查询字段,和find.DataSets属性一起使用 For i = 1 To AxMap1.Layers.Count ''查询每一层 findobj = AxMap1.Layers(i).Find ''查找的对象是第*层 layerds = AxMap1.DataSets.Item(AxMap1.Layers(i).Name) ''查询数据集Item(列名) findobj.FindDataset = Me.AxMap1.DataSets(AxMap1.Layers(i).Name) ''FindDataset查询数据集 For Each fid In layerds.Fields findobj.FindField = findobj.FindDataset.Fields(fid) ''Field查询字段 fdat = findobj.Search(findStr) ''AxMap1.CenterX = fdat.CenterX ''AxMap1.CenterY = fdat.CenterY AxMap1.Layers(i).Selection.se.Replace(fdat) ''添加网格表示选取(高亮) '' AxMap1.Layers(i).ClearSelection() Next fid Next ''If fdat = " " Then MsgBox( "没有找到任何数据! ","提示 ") ''AxMap1.AutoRedraw = False '' (禁止自动刷新) Me.AxMap1.DataSets.RemoveAll() -------------------------------------------- 编译通过后 Me.ComboBox2.Text 中输入图层名 ComboBox1.Text中输入内容 “FindObj.FindDataset = AxMap1.DataSets(Me.ComboBox2.Text & "dataset ")”这行总是提示 “No object was found using the index you specified.” 请问是怎么了? __________________________________________________________________________ 原文链接:https://www.f2er.com/vb/263948.html

猜你在找的VB相关文章