| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 820 人关注过本帖
标题:AE+C# 新建子窗体并添加完代买后 主窗体调用子窗体窗体后 控件都消失了 ...
只看楼主 加入收藏
sliverlight
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2014-12-1
结帖率:66.67%
收藏
 问题点数:0 回复次数:1 
AE+C# 新建子窗体并添加完代买后 主窗体调用子窗体窗体后 控件都消失了 变成空白怎么回事
这是我子窗体的代码   实现属性查询功能的   我在主窗体的单机按钮事件下  写的是{  
                                                                              AttributeQueryFrom frm =new AttributeQueryFrom();   
                                                                              frm.show();
                                                                              }

using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;

namespace MapControl
{
    public partial class AttributeQueryForm : Form
    {
        //地图数据
        private AxMapControl mMapControl;

        //选中图层
        private IFeatureLayer mFeatureLayer;
        public AttributeQueryForm(AxMapControl mapControl)
        {
            InitializeComponent();
            this.mMapControl = mapControl;
        }
          private void AttributeQueryForm_Load(object sender, EventArgs e)
        {
            //MapControl中没有图层时返回
            if (this.mMapControl.LayerCount <= 0)
                return;
            //获取MapControl中的全部图层名称,并加入ComboBox
            //图层
            ILayer pLayer;
            //图层名称
            string strLayerName;
            for (int i = 0; i < this.mMapControl.LayerCount; i++)
            {
                pLayer = this.mMapControl.get_Layer(i);
                strLayerName = pLayer.Name;
                //图层名称加入cboLayer
                this.cboLayer.Items.Add(strLayerName);
            }
            //默认显示第一个选项
            this.cboLayer.SelectedIndex = 0;
        }

        private void cboLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            //获取cboLayer中选中的图层
            mFeatureLayer = mMapControl.get_Layer(cboLayer.SelectedIndex) as IFeatureLayer;
            IFeatureClass pFeatureClass = mFeatureLayer.FeatureClass;
            //字段名称
            string strFldName;
            for (int i = 0; i < pFeatureClass.Fields.FieldCount; i++)
            {
                strFldName = pFeatureClass.Fields.get_Field(i).Name;
                //图层名称加入cboField
                this.cboField.Items.Add(strFldName);
            }
            //默认显示第一个选项
            this.cboField.SelectedIndex = 0;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            //定义图层,要素游标,查询过滤器,要素
            IFeatureCursor pFeatureCursor;
            IQueryFilter pQueryFilter;
            IFeature pFeature;
            IPoint pPoint;
            IEnvelope pEnv;
            pEnv = mMapControl.ActiveView.Extent;
            pPoint = new PointClass();
            pPoint.X = pEnv.XMin + pEnv.Width / 2;
            pPoint.Y = pEnv.YMin + pEnv.Height / 2;
            if (this.mMapControl.LayerCount <= 0)
                return;
            //获取图层
            mFeatureLayer = mMapControl.get_Layer(cboLayer.SelectedIndex) as IFeatureLayer;
            //清除上次查询结果
            this.mMapControl.Map.ClearSelection();
            this.mMapControl.ActiveView.Refresh();
            //pQueryFilter的实例化
            pQueryFilter = new QueryFilterClass();
            //设置查询过滤条件
            pQueryFilter.WhereClause = cboField.Text + "=" + txtValue.Text;
            //查询
            pFeatureCursor = mFeatureLayer.Search(pQueryFilter, true);
            //获取查询到的要素
            pFeature = pFeatureCursor.NextFeature();
            //判断是否获取到要素
            if (pFeature != null)
            {
                //选择要素
                this.mMapControl.Map.SelectFeature(mFeatureLayer, pFeature);
                //放大到要素
                pFeature.Shape.Envelope.CenterAt(pPoint);
                this.mMapControl.Extent = pFeature.Shape.Envelope;
            }
            else
            {
                //没有得到pFeature的提示
                MessageBox.Show("没有找到相关要素!", "提示");
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

     }
}
搜索更多相关主题的帖子: 新建 单机 
2014-12-09 08:48
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
收藏
得分:0 
调用了 AttributeQueryForm.Controls.add()方法没..要把控件加入到from 中
2014-12-30 16:18
快速回复:AE+C# 新建子窗体并添加完代买后 主窗体调用子窗体窗体后 控件都消 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016036 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved