<?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: ComboBox to add layers from folder, selected from .txt list in same folder in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1260284#M9449</link>
    <description>&lt;P&gt;A bit late on the response but Exams in college got the better of me. I was trying to avoid that since my focus for this project was to learn more about the add-in API. That being said, I went ahead and swapped to using the basic library (visual basic), and just used a delimited line reader, worked great.&lt;BR /&gt;&lt;BR /&gt;Now I can not for the life of me figure out why it won't add the layer. I have the "OnSelectionChange" method overwritten with&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Protected Overridable Overloads Sub OnSelectionChange(layerName As ComboBoxItem)&lt;BR /&gt;&lt;BR /&gt; If (layerName.ToString = "") Then&lt;BR /&gt;     MsgBox("Could not read layer name" + layerName.ToString)&lt;BR /&gt;     Return&lt;BR /&gt; End If&lt;BR /&gt;&lt;BR /&gt; MsgBox("getting layer file " + layerName.ToString)&lt;BR /&gt;&lt;BR /&gt; GetLayerFile(layerName.ToString)&lt;BR /&gt; MyBase.OnSelectionChange(layerName)&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;However neither msg box appears, and then GetLayerFile is&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;Public Sub GetLayerFile(ByVal layerName As String)&lt;BR /&gt;&lt;BR /&gt; Dim activeView As MapView&lt;BR /&gt; activeView = MapView.Active&lt;BR /&gt;&lt;BR /&gt; If Not File.Exists(FILE_NAME) Then&lt;BR /&gt;     MsgBox("File Does Not Exist")&lt;BR /&gt;     Return&lt;BR /&gt; End If&lt;BR /&gt;&lt;BR /&gt; Using lineReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(FILE_NAME)&lt;BR /&gt;&lt;BR /&gt; lineReader.TextFieldType = FileIO.FieldType.Delimited&lt;BR /&gt; lineReader.SetDelimiters(",")&lt;BR /&gt; Dim lineFields As String()&lt;BR /&gt;&lt;BR /&gt;  While Not lineReader.EndOfData&lt;BR /&gt;     Try&lt;BR /&gt;          lineFields = lineReader.ReadFields()&lt;BR /&gt;          If (lineFields(0) = layerName) Then&lt;BR /&gt;               AddLayerToActiveView(activeView, lineFields(1))&lt;BR /&gt;               MsgBox(lineFields(1))&lt;BR /&gt;          Return&lt;BR /&gt;          End If&lt;BR /&gt;&lt;BR /&gt;     MsgBox("Could not find layer")&lt;BR /&gt;&lt;BR /&gt;     Catch ex As Exception&lt;BR /&gt;     ' Let the user know what went wrong.&lt;BR /&gt;     MsgBox("The Layer Path Cannot be read: Line " &amp;amp; ex.Message &amp;amp; "is not valid and will be skipped.")&lt;BR /&gt;     Return&lt;BR /&gt;&lt;BR /&gt;     End Try&lt;BR /&gt;&lt;BR /&gt;   End While&lt;BR /&gt;&lt;BR /&gt; End Using&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;P&gt;I don't know if there's anything blaringly obvious, this is the AddLayerToActiveView method&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;Public Async Sub AddLayerToActiveView(ByVal activeView As MapView, ByVal layerPathFile As System.String) &lt;BR /&gt; Dim Path As Uri&lt;BR /&gt; Path = New Uri(layerPathFile)&lt;BR /&gt;&lt;BR /&gt; Try&lt;BR /&gt;      Await QueuedTask.Run(Sub()&lt;BR /&gt;           LayerFactory.Instance.CreateLayer(Path, MapView.Active.Map)&lt;BR /&gt;      End Sub)&lt;BR /&gt; Catch e As Exception&lt;BR /&gt;      ' Let the user know what went wrong.&lt;BR /&gt;      MsgBox("The Layer Path Cannot be read: code2")&lt;BR /&gt;      MsgBox(e.Message)&lt;BR /&gt;&lt;BR /&gt; End Try&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Feb 2023 22:41:02 GMT</pubDate>
    <dc:creator>Dood345</dc:creator>
    <dc:date>2023-02-21T22:41:02Z</dc:date>
    <item>
      <title>ComboBox to add layers from folder, selected from .txt list in same folder</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1256668#M9398</link>
      <description>&lt;P&gt;I think I've gotten close to getting this working but the function to read in the table stored in the .txt file can not read the table. I am probably using the wrong method, I'm using a FileSystemDatastore.OpenDataset(Of Table)(...).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dood345_0-1675974127252.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62476i8DF6A0FF36AF12F3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dood345_0-1675974127252.png" alt="Dood345_0-1675974127252.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample of the list of layers .txt (organized like a .csv):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;LayerName,Path&lt;BR /&gt;Annotation Text,DRIVE:\FileLocation\LayerFiles\ANNOTATION TEXT.lyr&lt;BR /&gt;-----Land &amp;amp; Property (Choose from items below)-----,NOTHING&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Below is a sample of the first read in of the table/.txt:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Public Async Sub UpdateCombo()&lt;/P&gt;&lt;P&gt;Dim WorkspaceF As FileSystemDatastore&lt;BR /&gt;Dim FileConnection As FileSystemConnectionPath&lt;BR /&gt;Dim Table As Table&lt;BR /&gt;Dim Cur As RowCursor&lt;BR /&gt;Dim Row As Row&lt;/P&gt;&lt;P&gt;Dim GDBLocation As Uri&lt;BR /&gt;GDBLocation = New Uri("DRIVE:\FileLocation\LayerFiles\")&lt;/P&gt;&lt;P&gt;Try&lt;BR /&gt;Await QueuedTask.Run(Sub()&lt;BR /&gt;If Not File.Exists(FILE_NAME) Then&lt;BR /&gt;MsgBox("File Does Not Exist")&lt;/P&gt;&lt;P&gt;End If&lt;BR /&gt;FileConnection = New FileSystemConnectionPath(GDBLocation, FileSystemDatastoreType.Shapefile)&lt;BR /&gt;WorkspaceF = New FileSystemDatastore(FileConnection)&lt;BR /&gt;Table = WorkspaceF.OpenDataset(Of Table)("coa_LAYERS_list.txt")&lt;BR /&gt;MsgBox(Table.GetCount)&lt;BR /&gt;Cur = Table.Search(Nothing, False)&lt;BR /&gt;Cur.MoveNext()&lt;BR /&gt;Row = Cur.Current&lt;BR /&gt;Do Until Row Is Nothing&lt;/P&gt;&lt;P&gt;Add(New ComboBoxItem(Row.Item(0).ToString))&lt;BR /&gt;Cur.MoveNext()&lt;BR /&gt;Row = Cur.Current&lt;BR /&gt;Loop&lt;/P&gt;&lt;P&gt;Table = Nothing&lt;BR /&gt;Row = Nothing&lt;BR /&gt;WorkspaceF = Nothing&lt;BR /&gt;FileConnection = Nothing&lt;BR /&gt;Cur = Nothing&lt;BR /&gt;GC.Collect()&lt;BR /&gt;End Sub)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;I do use " (QF.WhereClause = "LayerName = '" &amp;amp; Value &amp;amp; "'") " later but for now I'm just trying to figure out why the table is not being read.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 20:22:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1256668#M9398</guid>
      <dc:creator>Dood345</dc:creator>
      <dc:date>2023-02-09T20:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: ComboBox to add layers from folder, selected from .txt list in same folder</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1256765#M9399</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seeing you're reading just a .txt file - I would recommend using standard .NET read/write classes/methods to open your file rather than the FileSystemConnectionPath object.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-text-from-files-with-a-streamreader" target="_blank"&gt;https://learn.microsoft.com/en-us/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-text-from-files-with-a-streamreader&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This link has a code snippet which seems to suit your situation -&amp;nbsp; opening a text file and reading lines.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 22:25:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1256765#M9399</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2023-02-09T22:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: ComboBox to add layers from folder, selected from .txt list in same folder</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1260284#M9449</link>
      <description>&lt;P&gt;A bit late on the response but Exams in college got the better of me. I was trying to avoid that since my focus for this project was to learn more about the add-in API. That being said, I went ahead and swapped to using the basic library (visual basic), and just used a delimited line reader, worked great.&lt;BR /&gt;&lt;BR /&gt;Now I can not for the life of me figure out why it won't add the layer. I have the "OnSelectionChange" method overwritten with&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Protected Overridable Overloads Sub OnSelectionChange(layerName As ComboBoxItem)&lt;BR /&gt;&lt;BR /&gt; If (layerName.ToString = "") Then&lt;BR /&gt;     MsgBox("Could not read layer name" + layerName.ToString)&lt;BR /&gt;     Return&lt;BR /&gt; End If&lt;BR /&gt;&lt;BR /&gt; MsgBox("getting layer file " + layerName.ToString)&lt;BR /&gt;&lt;BR /&gt; GetLayerFile(layerName.ToString)&lt;BR /&gt; MyBase.OnSelectionChange(layerName)&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;However neither msg box appears, and then GetLayerFile is&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;Public Sub GetLayerFile(ByVal layerName As String)&lt;BR /&gt;&lt;BR /&gt; Dim activeView As MapView&lt;BR /&gt; activeView = MapView.Active&lt;BR /&gt;&lt;BR /&gt; If Not File.Exists(FILE_NAME) Then&lt;BR /&gt;     MsgBox("File Does Not Exist")&lt;BR /&gt;     Return&lt;BR /&gt; End If&lt;BR /&gt;&lt;BR /&gt; Using lineReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(FILE_NAME)&lt;BR /&gt;&lt;BR /&gt; lineReader.TextFieldType = FileIO.FieldType.Delimited&lt;BR /&gt; lineReader.SetDelimiters(",")&lt;BR /&gt; Dim lineFields As String()&lt;BR /&gt;&lt;BR /&gt;  While Not lineReader.EndOfData&lt;BR /&gt;     Try&lt;BR /&gt;          lineFields = lineReader.ReadFields()&lt;BR /&gt;          If (lineFields(0) = layerName) Then&lt;BR /&gt;               AddLayerToActiveView(activeView, lineFields(1))&lt;BR /&gt;               MsgBox(lineFields(1))&lt;BR /&gt;          Return&lt;BR /&gt;          End If&lt;BR /&gt;&lt;BR /&gt;     MsgBox("Could not find layer")&lt;BR /&gt;&lt;BR /&gt;     Catch ex As Exception&lt;BR /&gt;     ' Let the user know what went wrong.&lt;BR /&gt;     MsgBox("The Layer Path Cannot be read: Line " &amp;amp; ex.Message &amp;amp; "is not valid and will be skipped.")&lt;BR /&gt;     Return&lt;BR /&gt;&lt;BR /&gt;     End Try&lt;BR /&gt;&lt;BR /&gt;   End While&lt;BR /&gt;&lt;BR /&gt; End Using&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;P&gt;I don't know if there's anything blaringly obvious, this is the AddLayerToActiveView method&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;Public Async Sub AddLayerToActiveView(ByVal activeView As MapView, ByVal layerPathFile As System.String) &lt;BR /&gt; Dim Path As Uri&lt;BR /&gt; Path = New Uri(layerPathFile)&lt;BR /&gt;&lt;BR /&gt; Try&lt;BR /&gt;      Await QueuedTask.Run(Sub()&lt;BR /&gt;           LayerFactory.Instance.CreateLayer(Path, MapView.Active.Map)&lt;BR /&gt;      End Sub)&lt;BR /&gt; Catch e As Exception&lt;BR /&gt;      ' Let the user know what went wrong.&lt;BR /&gt;      MsgBox("The Layer Path Cannot be read: code2")&lt;BR /&gt;      MsgBox(e.Message)&lt;BR /&gt;&lt;BR /&gt; End Try&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 22:41:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1260284#M9449</guid>
      <dc:creator>Dood345</dc:creator>
      <dc:date>2023-02-21T22:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: ComboBox to add layers from folder, selected from .txt list in same folder</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1260760#M9455</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you change the definition of your OnSelectionChange function to the following and see if that helps with the method firing when a choice is made in the combobox.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Protected Overrides Sub OnSelectionChange(layerName As ComboBoxItem)&lt;/P&gt;&lt;P&gt;(so it is Overrides not Overridable Overloads)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 03:30:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1260760#M9455</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2023-02-23T03:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: ComboBox to add layers from folder, selected from .txt list in same folder</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1260964#M9458</link>
      <description>&lt;P&gt;I think that did it, now I just have to sort out my string comparison to identify the layers to add! Hopefully I'm good from here. Thank you, Narelle, for all the help.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I think I see why that was an issue, overridable overloads basically means that the method I wrote could be overridden and is just another overload for "onSelectionChange" so might not even be called since the program would just do a standard call not the overloaded version.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 16:27:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/combobox-to-add-layers-from-folder-selected-from/m-p/1260964#M9458</guid>
      <dc:creator>Dood345</dc:creator>
      <dc:date>2023-02-23T16:27:24Z</dc:date>
    </item>
  </channel>
</rss>

