gisbuffon
路人甲
路人甲
  • 注册日期2005-06-21
  • 发帖数35
  • QQ
  • 铜币221枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1558回复:0

[求助]请帮我看看这几个问题是怎么回事C#+MO

楼主#
更多 发布于:2007-11-21 16:34
<P>我复制了<a href="http://www.gisempire.com/bbs/dispbbs.asp?boardID=39;ID=60126;page=1" target="_blank" >http://www.gisempire.com/bbs/dispbbs.asp?boardID=39;ID=60126;page=1</A></P>
<P><FONT face=Verdana color=#61b713><STRONG>sbitx</STRONG><FONT color=#000000><STRONG>发的代码,谢谢sbitx!</STRONG></FONT></FONT></P>
<P><FONT face=Verdana color=#61b713><FONT color=#000000>运行时候发现几个错误,自己搞不懂,请大家帮我看看</FONT></FONT></P>
<P>E:\c#\open\Form1.cs(155): 找不到类型或命名空间名称“MapObjects2”(是否缺少 using 指令或程序集引用?)<BR>E:\c#\open\Form1.cs(156): 名称“objDataConn”在类或命名空间“open.Form1”中不存在<BR>E:\c#\open\Form1.cs(157): 名称“objMapLayer”在类或命名空间“open.Form1”中不存在<BR>E:\c#\open\Form1.cs(158): 找不到类型或命名空间名称“objDataConn”(是否缺少 using 指令或程序集引用?)<BR>E:\c#\open\Form1.cs(160): 找不到类型或命名空间名称“objDataConn”(是否缺少 using 指令或程序集引用?)<BR>E:\c#\open\Form1.cs(162): 名称“objGeoDataset”在类或命名空间“open.Form1”中不存在<BR>E:\c#\open\Form1.cs(163): 找不到类型或命名空间名称“objMapLayer”(是否缺少 using 指令或程序集引用?)<BR>E:\c#\open\Form1.cs(164): 名称“objMapLayer”在类或命名空间“open.Form1”中不存在</P>
<P>代码</P>
<P>using System;<BR>using System.Drawing;<BR>using System.Collections;<BR>using System.ComponentModel;<BR>using System.Windows.Forms;<BR>using System.Data; <BR>using System.Text; <BR>using System.IO;<BR>using ESRI.MapObjects2.Core;</P>
<P>namespace open<BR>{<BR> /// <summary><BR> /// Form1 的摘要说明。<BR> /// </summary><BR> public class Form1 : System.Windows.Forms.Form<BR> {<BR>  private ESRI.MapObjects2.Core.AxMap axMap1;<BR>  private System.Windows.Forms.ToolBar toolBar1;<BR>  private System.Windows.Forms.ToolBarButton tool_addlayer;<BR>  /// <summary><BR>  /// 必需的设计器变量。<BR>  /// </summary><BR>  private System.ComponentModel.Container components = null;</P>
<P>  public Form1()<BR>  {<BR>   //<BR>   // Windows 窗体设计器支持所必需的<BR>   //<BR>   InitializeComponent();</P>
<P>   //<BR>   // TOD 在 InitializeComponent 调用后添加任何构造函数代码<BR>   //<BR>  }</P>
<P>  /// <summary><BR>  /// 清理所有正在使用的资源。<BR>  /// </summary><BR>  protected override void Dispose( bool disposing )<BR>  {<BR>   if( disposing )<BR>   {<BR>    if (components != null) <BR>    {<BR>     components.Dispose();<BR>    }<BR>   }<BR>   base.Dispose( disposing );<BR>  }</P>
<P>  #region Windows 窗体设计器生成的代码<BR>  /// <summary><BR>  /// 设计器支持所需的方法 - 不要使用代码编辑器修改<BR>  /// 此方法的内容。<BR>  /// </summary><BR>  private void InitializeComponent()<BR>  {<BR>   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));<BR>   this.axMap1 = new ESRI.MapObjects2.Core.AxMap();<BR>   this.toolBar1 = new System.Windows.Forms.ToolBar();<BR>   this.tool_addlayer = new System.Windows.Forms.ToolBarButton();<BR>   ((System.ComponentModel.ISupportInitialize)(this.axMap1)).BeginInit();<BR>   this.SuspendLayout();<BR>   // <BR>   // axMap1<BR>   // <BR>   this.axMap1.Dock = System.Windows.Forms.DockStyle.Fill;<BR>   this.axMap1.Location = new System.Drawing.Point(0, 0);<BR>   this.axMap1.Name = "axMap1";<BR>   this.axMap1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMap1.OcxState")));<BR>   this.axMap1.Size = new System.Drawing.Size(424, 266);<BR>   this.axMap1.TabIndex = 0;<BR>   this.axMap1.MouseDownEvent += new ESRI.MapObjects2.Core.MouseDownEventHandler(this.axMap1_MouseDownEvent);<BR>   // <BR>   // toolBar1<BR>   // <BR>   this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {<BR>                      this.tool_addlayer});<BR>   this.toolBar1.DropDownArrows = true;<BR>   this.toolBar1.Location = new System.Drawing.Point(0, 0);<BR>   this.toolBar1.Name = "toolBar1";<BR>   this.toolBar1.ShowToolTips = true;<BR>   this.toolBar1.Size = new System.Drawing.Size(424, 28);<BR>   this.toolBar1.TabIndex = 1;<BR>   this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);<BR>   // <BR>   // Form1<BR>   // <BR>   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);<BR>   this.ClientSize = new System.Drawing.Size(424, 266);<BR>   this.Controls.Add(this.toolBar1);<BR>   this.Controls.Add(this.axMap1);<BR>   this.Name = "Form1";<BR>   this.Text = "Form1";<BR>   ((System.ComponentModel.ISupportInitialize)(this.axMap1)).EndInit();<BR>   this.ResumeLayout(false);</P>
<P>  }<BR>  #endregion</P>
<P>  /// <summary><BR>  /// 应用程序的主入口点。<BR>  /// </summary><BR>  [STAThread]<BR>  static void Main() <BR>  {<BR>   Application.Run(new Form1());<BR>  }<BR>  //打开“打开文件对话框”的SHOW函数过程,</P>
<P>  private void ShowOpenFileDialog()<BR>        {<BR>            DialogResult  drfile;<BR>            string strFilePath,strFileName,strSpliter1;         <BR>            int intCount;<BR>            int intCount2;  <BR>            strSpliter1=@"";           <BR>            strFilePath="";<BR>            strFileName="";                <BR>            openFileDialog1.FileName="";<BR>            drfile=openFileDialog1.ShowDialog();<BR>   <BR>  //分别读取文件名和文件的路径,<BR>            if (drfile == DialogResult.OK)<BR>            {<BR>                strSpliter1 = openFileDialog1.FileName;<BR>                intCount=strSpliter1.Length-4;   <BR>                intCount2=strSpliter1.LastIndexOf('\\');<BR>                <BR>    for(int j=0;j<=intCount2;j++)<BR>                {<BR>                    strFilePath=strFilePath+strSpliter1[j];<BR>                }<BR>                for(int i=intCount;i>0;i--)<BR>                {<BR>                    if(strSpliter1=='\\')<BR>                    {<BR>                      strFileName=strSpliter1.Substring(i+1);<BR>                      break;<BR>                     }<BR>                }<BR>             }<BR>  <BR>     //调用加载图层的方法<BR>           AddLayer(strFilePath,strFileName);<BR>        }<BR>  <BR>  //加载图层的方法      <BR>        private void AddLayer(string strDatabase,string strDatasetName)<BR>        {<BR>            MapObjects2.DataConnection objDataConn;<BR>            MapObjects2.GeoDataset objGeoDataset;<BR>            MapObjects2.MapLayer objMapLayer;<BR>            objDataConn=new MapObjects2.DataConnection();<BR>            objMapLayer=new MapObjects2.MapLayer();<BR>            objDataConn.Database =strDatabase;<BR>            <BR>   if(objDataConn.Connect()==true)<BR>            {    <BR>                objGeoDataset=objDataConn.FindGeoDataset(strDatasetName);<BR>                objMapLayer.GeoDataset=objGeoDataset;                             <BR>                axMap1.Layers.Add(objMapLayer);<BR>                axMap1.Refresh();<BR>            }<BR>         }</P>
<P> private void axMap1_MouseDownEvent(object sender, ESRI.MapObjects2.Core.MouseDownEventArgs e)<BR>  {<BR>  <BR>  }</P>
<P>  private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)<BR>  {<BR>   if(e.Button.Tag.ToString()=="tool_addlayer")<BR>            {<BR>                 ShowOpenFileDialog();<BR>            }<BR>  }<BR> }<BR>}</P>
喜欢0 评分0
游客

返回顶部