⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档.txt

📁 这个是mapxtreme2004 C# ASP。NET 关于显示图元信息的代码
💻 TXT
字号:
private void mapControl1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{ 

//如果没有转载任何tab文件,则返回
if(mapControl1.Map.Layers.Count == 0 )//currentLayerName是顶层Layer的名字,同时也是Table的名字
return;
MapInfo.Engine.Selection selection=MapInfo.Engine.Session.Current.Selections.DefaultSelection;
MapInfo.Data.Table table=MapInfo.Engine.Session.Current.Catalog.GetTable("temp");

 
MapInfo.Data.IResultSetFeatureCollection featureCollection=selection[table];
//如果没有选中任何图元,或者选中多个图元,则返回
if(featureCollection==null||featureCollection.Count!=1)
return;


//取第一个图元
MapInfo.Geometry.Geometry geometry=featureCollection[0].Geometry;
//创建连接和命令来查询table中的数据
MapInfo.Data.MIConnection connection=new MapInfo.Data.MIConnection();
MapInfo.Data.MICommand command=connection.CreateCommand();
command.CommandText="SELECT MI_Help FROM temp";
connection.Open();
MapInfo.Data.MIDataReader dataReader=command.ExecuteReader();
int n=dataReader.FieldCount;
            
this.textBox2.Clear();

this.textBox2.AppendText("\n");
while(dataReader.Read())
{
for(int i=0;i<n;i++)
{
  object o=dataReader.GetValue(i);
  if(o==DBNull.Value)
  this.textBox2.AppendText("null\t");
  else
  this.textBox2.AppendText(o.ToString()+"\t");
}

this.textBox2.AppendText("\n");
}
connection.Dispose();
connection.Close();

this.textBox2.Location=new System.Drawing.Point(e.X,e.Y+50);
this.textBox2.Visible=true;

}


private void mapControl1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
    this.textBox2.Visible=false;
                    }

自己写了这样一段,是在图元上按下鼠标,显示提示信息,松开鼠标,提示信息消失。运行能够成功,但是程序时提示出错:未将对象引用设置到对象实例。
求高人给诊断!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -