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

来源:互联网 发布:行助手是什么软件 编辑:程序博客网 时间:2024/06/07 01:47
VB.NET源码-156个实用实例哦……<script type="text/javascript"><!--google_ad_client = "pub-8333940862668978";/* 728x90, 创建于 08-11-30 */google_ad_slot = "4485230109";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
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.”
请问是怎么了?
__________________________________________________________________________
原创粉丝点击