Wrox Programmer Forums
|
BOOK: Beginning ArcGIS for Desktop Development using .NET
This is the forum to discuss the Wrox book Beginning ArcGIS for Desktop Development using .NET by Pouria Amirian; ISBN: 978-1-118-44254-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ArcGIS for Desktop Development using .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 29th, 2015, 11:35 AM
Registered User
 
Join Date: May 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default LayersOfMap Try It Out example in Ch. 6

I have tried the simple example starting on page 168 in VB .NET, following the instructions and then copying and pasting the vb code that I downloaded. From what I can tell, my solution is the same as the one provided in the downloaded code, yet, when I try to use the tool (debug mode), the button grays out and no window pops up.

It works fine with the code provided with the book (after changing the application to version 10.2). I have checked all the associated files and they are identical except for the LayersOfMap.vbproj.FileListAbsolute.txt and AddInID.txt files, and the value between <AddInID> and </AddInID> in the Config.esriaddinx file. Both solutions are using the .NET 3.5 framework.

Any suggestions? I would prefer to be able to get a version that I created from scratch working rather than always copy the downloaded code. I was able to get some simpler Try It Out projects in Chapter 2 to work.
 
Old May 29th, 2015, 04:16 PM
Registered User
 
Join Date: May 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

I started from scratch and defined the variables and initialized them in separate lines of code. I'm not sure what made the difference, but it worked this time. Here is the code I used for LayersOfMapButton.vb:

Code:
Imports ESRI.ArcGIS.ArcMapUI
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Framework


Public Class LayersOfMapButton
    Inherits ESRI.ArcGIS.Desktop.AddIns.Button

    Public Sub New()

    End Sub

    Protected Overrides Sub OnClick()
        Dim pData As String
        Dim pMxDoc As IMxDocument
        Dim pMap As IMap
        pData = ""
        pMxDoc = My.ArcMap.Application.Document
        pMap = pMxDoc.FocusMap
        'Using layer count property

        Dim pLayer As ILayer
        For i As Integer = 0 To pMap.LayerCount - 1
            pLayer = pMap.Layer(i)
            pData = pData + " >> " + pLayer.Name + vbNewLine
        Next
        pData = pData + String.Format("{0} Map contains {1} layers" + vbNewLine, pMap.Name, pMap.LayerCount)
        pLayer = Nothing

        pData = pData + "-------------------------" + vbNewLine
        pData = pData + "Using layers property" + vbNewLine
        Dim pEnumLayer As IEnumLayer
        pEnumLayer = pMap.Layers
        pLayer = pEnumLayer.Next()
        Dim j As Integer
        j = 0
        While pLayer IsNot Nothing
            j = j + 1
            pData = pData + " >> " + pLayer.Name + vbNewLine
            pLayer = pEnumLayer.Next()
        End While
        pData = pData + String.Format("{0} Map contains {1} layer(s)" + vbNewLine, pMap.Name, j)

        Dim msgForm As New Message()
        msgForm.lbl.Text = pData
        msgForm.ShowDialog()

    End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 4 and Ch 13/15 - controls and the DataPager AlanWheeler BOOK: Beginning ASP.NET 4.5 : in C# and VB 3 February 24th, 2014 04:56 PM
Ch 9-but will learn more abt User Controls (ch 8) btcomp BOOK: Beginning ASP.NET 4 : in C# and VB 1 August 24th, 2010 11:40 AM
Search ch 13, ch 16 sporik BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 0 October 27th, 2009 04:44 PM
Ch. 4 & Ch. 12 athena BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 23rd, 2004 10:54 AM
ch. 2 with C# Justin BOOK: Beginning ASP.NET 1.0 1 July 10th, 2003 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.