我需要帮助在c#中将所选的特征颜色更改为红色

515
1
跳到解决方案
06-09-2021 03:59 PM
worlanyo
通过
新的因素

IFeatureLayer pFeatureLayer;

IFeatureCursor pFeatureCursor;
IQueryFilter pQueryFilter;
ESRI.ArcGIS.Geodatabase.IFeature pFeature;
pFeatureLayer = this.axMapControl1.Map.get_Layer(0) as IFeatureLayer;
如果(pFeatureLayer。名字!= "包裹")
返回;
this.axMapControl1.Map.ClearSelection ();
pQueryFilter = new QueryFilterClass();

pQueryFilter。where eclause = "cc_number='LEKMA'";


pFeatureCursor = pFeatureLayer。搜索(pQueryFilter,真实);
pFeature = pFeatureCursor.NextFeature();


IFeatureSelection featureSelection = pFeature as IFeatureSelection;



if (pFeature != null)

this.axMapControl1.Map。SelectFeature (pFeatureLayer pFeature);
this.axMapControl1。Extent = pFeature.Shape.Envelope;


其他的

对话框。显示("Not found" + "LEKMA");

0荣誉
1解决方案

接受的解决方案
GintautasKmieliauskas
定期贡献者II

你好,

一开始你不能从IFeature施放到ifeaturesselection。你可以将IFeatureLayer转换为IFeatureSelection。

所以它是:

IFeatureSelection featureSelection = pFeatureLayer as IFeatureSelection;

如果你查看你的图层属性-选择选项卡,你会发现显示选择的选项:

gintautaskmieliauskas_0 - 1623303882562. - png

第一个是ArcMap设置,它改变了所有图层的选择显示。我认为你不应该把所有图层的选择都改成红色。如果你这样做,那么你应该在IMapDescription2上使用SelectionColor。

如果你对第三个选项感兴趣,那么你应该在ILayerDescription上使用SelectionColor。

更多关于这两种情况的信息:

——ILayerDescription。SelectionColor属性(ArcObjects .NET 10.8 SDK)

如果你想标记一个特殊的选择,你可以使用IGraphicsContainer在你的特征上绘制你想要的颜色或形状的图形元素。

在原帖子中查看解决方案

1回复
GintautasKmieliauskas
定期贡献者II

你好,

一开始你不能从IFeature施放到ifeaturesselection。你可以将IFeatureLayer转换为IFeatureSelection。

所以它是:

IFeatureSelection featureSelection = pFeatureLayer as IFeatureSelection;

如果你查看你的图层属性-选择选项卡,你会发现显示选择的选项:

gintautaskmieliauskas_0 - 1623303882562. - png

第一个是ArcMap设置,它改变了所有图层的选择显示。我认为你不应该把所有图层的选择都改成红色。如果你这样做,那么你应该在IMapDescription2上使用SelectionColor。

如果你对第三个选项感兴趣,那么你应该在ILayerDescription上使用SelectionColor。

更多关于这两种情况的信息:

——ILayerDescription。SelectionColor属性(ArcObjects .NET 10.8 SDK)

如果你想标记一个特殊的选择,你可以使用IGraphicsContainer在你的特征上绘制你想要的颜色或形状的图形元素。