高亮显示在属性表中选中的要素

高亮显示在属性表中选中的要素  

/// <summary>
/// 高亮显示在属性表中选中的要素
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
    frmMap.m_mapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
    IQueryFilter pQuery = new QueryFilterClass();
    int count = this.dataGridView1.SelectedRows.Count;
    string val;
    string col;
    col = this.dataGridView1.Columns[0].Name;
    //当只选中一行时
    if(count==1)
    {
        val = this.dataGridView1.SelectedRows[0].Cells[col].Value.ToString();
        //设置高亮要素的查询条件
        pQuery.WhereClause = col + "=" + val;
    }
    else//当选中多行时
    {
        int i;
        string str;
        for (i = 0; i < count-1; i++)
        {
            val = this.dataGridView1.SelectedRows[i].Cells[col].Value.ToString();
            str = col + "=" + val + " OR ";
            pQuery.WhereClause += str;
        }
        //添加最后一个要素的条件
        val = this.dataGridView1.SelectedRows[i].Cells[col].Value.ToString();
        str = col + "=" + val;
        pQuery.WhereClause += str;
    }
    IFeatureLayer pFeatureLayer = layer as IFeatureLayer;
    IFeatureSelection pFeatSelection;
    pFeatSelection = pFeatureLayer as IFeatureSelection;
    pFeatSelection.SelectFeatures(pQuery, esriSelectionResultEnum.esriSelectionResultNew,false);
    frmMap.m_mapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);                                  
}

转载于:https://www.cnblogs.com/xinghai/archive/2012/06/21/2557981.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C#结合ArcEngine中,实现双击属性表缩放至选择要素高亮的功能可以按照以下步骤进行: 1. 首先,你需要在ArcEngine中获取到选中要素。你可以通过以下代码来实现: ```csharp // 获取当前地图控件 AxMapControl mapControl = yourMapControl; // 获取选择集 IFeatureSelection featureSelection = mapControl.Map.FeatureSelection; // 判断是否有选中要素 if (featureSelection.SelectionSet.Count > 0) { // 获取选中要素 IEnumIDs enumIDs = featureSelection.SelectionSet.IDs; int featureID = enumIDs.Next(); // 高亮选中要素 IFeatureLayer featureLayer = mapControl.Map.get_Layer(layerIndex) as IFeatureLayer; IFeature feature = featureLayer.FeatureClass.GetFeature(featureID); mapControl.FlashShape(feature.Shape); } ``` 2. 接下来,你需要根据选中要素来进行缩放操作。你可以使用以下代码来实现: ```csharp // 获取选中要素的范围 IGeometry geometry = feature.Shape; IEnvelope envelope = geometry.Envelope; // 设置地图控件的显示范围为选中要素的范围 mapControl.Extent = envelope; mapControl.Refresh(); ``` 3. 最后,你可以使用高亮选中要素的方法来实现高亮效果。在上面的代码中,我们使用了`mapControl.FlashShape`方法来实现闪烁效果。你也可以使用其他方法来实现更符合你需求的高亮效果。 注意:以上代码只是简单示例,实际应用中你可能需要根据你的具体需求进行适当的修改和完善。另外,你还需要确保在ArcEngine开发环境中正确引用了相关的ArcObjects库。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值