<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: vb.net arcobjects select a layer in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/vb-net-arcobjects-select-a-layer/m-p/94089#M2516</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Li,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You say you have used the snippet to &lt;EM&gt;get&lt;/EM&gt; the selected layer but then you say you want to select it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The VBA code below shows how to set a layer to be the selected layer in the TOC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14141627926522185 jive_text_macro" jivemacro_uid="_14141627926522185"&gt;
&lt;P&gt;Public Sub SetLayerToBeSelected()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMXD As IMxDocument&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMXD = ThisDocument&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pLayer As ILayer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pLayer = pMXD.FocusMap.Layer(2) ' tree is zero-based so this is 3rd layer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pContentsView As IContentsView&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pContentsView = pMXD.ContentsView(0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pContentsView.SelectedItem = pLayer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pMXD.UpdateContents&lt;/P&gt;
&lt;P&gt;End Sub&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Oct 2014 15:00:02 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2014-10-24T15:00:02Z</dc:date>
    <item>
      <title>vb.net arcobjects select a layer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vb-net-arcobjects-select-a-layer/m-p/94088#M2515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using Get Selected Feature Layer In Contents View by following the sample code from ESRI:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//004900000016000000" title="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//004900000016000000"&gt;ArcObjects 10 .NET SDK Help&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But sometimes there is no layer selected, which cause error in the application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to find the way to select a layer through arcobjects (as in the following picture), but no luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="nnnnnnnnnnnnnnnnnnnnn.jpg" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/20441_nnnnnnnnnnnnnnnnnnnnn.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anybody has any advice on this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using arcmap and arcobjects 10.2.2 and vb.net arcmap add-in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 07:02:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vb-net-arcobjects-select-a-layer/m-p/94088#M2515</guid>
      <dc:creator>LiYao</dc:creator>
      <dc:date>2014-10-13T07:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: vb.net arcobjects select a layer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vb-net-arcobjects-select-a-layer/m-p/94089#M2516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Li,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You say you have used the snippet to &lt;EM&gt;get&lt;/EM&gt; the selected layer but then you say you want to select it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The VBA code below shows how to set a layer to be the selected layer in the TOC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14141627926522185 jive_text_macro" jivemacro_uid="_14141627926522185"&gt;
&lt;P&gt;Public Sub SetLayerToBeSelected()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMXD As IMxDocument&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMXD = ThisDocument&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pLayer As ILayer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pLayer = pMXD.FocusMap.Layer(2) ' tree is zero-based so this is 3rd layer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pContentsView As IContentsView&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pContentsView = pMXD.ContentsView(0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pContentsView.SelectedItem = pLayer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pMXD.UpdateContents&lt;/P&gt;
&lt;P&gt;End Sub&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2014 15:00:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vb-net-arcobjects-select-a-layer/m-p/94089#M2516</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2014-10-24T15:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: vb.net arcobjects select a layer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vb-net-arcobjects-select-a-layer/m-p/94090#M2517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Duncan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 00:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vb-net-arcobjects-select-a-layer/m-p/94090#M2517</guid>
      <dc:creator>LiYao</dc:creator>
      <dc:date>2014-10-27T00:32:05Z</dc:date>
    </item>
  </channel>
</rss>

