jhanson5874

ADD LAYERS TO ARCMAP FROM LISTBOX

Discussion created by jhanson5874 on Jan 9, 2014
I am creating an Add-in with ArcGIS 10.1 using MS Visual Studio 2010 VB.net

I have a button on my toolbar that opens a form (frmFieldDescription) with a listbox (ListBox1) that is populated with a list of .lyrs from a directory (G:\PPACG\)......this works fine.

On the form I created another button (Button1_Click).....I've been trying to get this button to load the selected .lyr(s) from the listbox to be loaded onto ArcMap's TOC.

Any suggestions-code?

See my code that is competed so far below:


Imports System.Windows.Forms
Imports System
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Framework
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.ArcMapUI


Public Class frmFieldDescription

  



    Private Sub frmFieldDescription_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim directoryInfo As IO.DirectoryInfo = New IO.DirectoryInfo("G:\PPACG\")

        If Not (directoryInfo Is Nothing) Then

            Dim fileInfo As IO.FileInfo() = directoryInfo.GetFiles
            Dim i As Int32

            For i = 0 To fileInfo.GetUpperBound(0)

                ListBox1.Items.Add(fileInfo(i).Name)

            Next i

        End If
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        MsgBox("nnnn", , "Oops")   'JH at least this works
        'JH THE FOLLOWING WORKS WHEN I CLICK ON THE BUTTON
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
      
    End Sub
End Class

Outcomes