Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > BOOK: Beginning ArcGIS for Desktop Development using .NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 29th, 2015, 11:35 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #2 (permalink)  
Old May 29th, 2015, 04:16 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03: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



All times are GMT -4. The time now is 06:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.