Select to view content in your preferred language

Looping though selection does not show values

760
1
Jump to solution
09-27-2012 07:59 AM
MichaelNelson1
Occasional Contributor
Created a little tool that will give information about the selected features. But if I have not started an edit session values for each feature do not show up. I can start and stop an edit session and it work fine, so you dont have to be editing. Im guessing there is something easy I need to initialize. Or perhaps I need to get the features differently?

        Dim enumFeat As IEnumFeature = Nothing
        Dim selFeat As IFeature

            enumFeat = My.ArcMap.Document.FocusMap.FeatureSelection
            selFeat = enumFeat.Next
            Do Until selFeat Is Nothing
                    MsgBox(selFeat.Value(selFeat.Fields.FindField("Field_Name")))
                    selFeat = enumFeat.Next
                Loop
0 Kudos
1 Solution

Accepted Solutions
MichaelNelson1
Occasional Contributor
I have answered my own question. Need to use IEnumFeatureSetup to setup what fields are returned with selection

        Dim enumFeat As IEnumFeature = Nothing
        Dim selFeat As IFeature
        Dim enumFeatSet As IEnumFeatureSetup

                enumFeat = My.ArcMap.Document.FocusMap.FeatureSelection
                enumFeatSet = enumFeat
                enumFeatSet.AllFields = True

                selFeat = enumFeat.Next
                Do Until selFeat Is Nothing
                    MsgBox(selFeat.OID)
                    selFeat = enumFeat.Next
                Loop

View solution in original post

0 Kudos
1 Reply
MichaelNelson1
Occasional Contributor
I have answered my own question. Need to use IEnumFeatureSetup to setup what fields are returned with selection

        Dim enumFeat As IEnumFeature = Nothing
        Dim selFeat As IFeature
        Dim enumFeatSet As IEnumFeatureSetup

                enumFeat = My.ArcMap.Document.FocusMap.FeatureSelection
                enumFeatSet = enumFeat
                enumFeatSet.AllFields = True

                selFeat = enumFeat.Next
                Do Until selFeat Is Nothing
                    MsgBox(selFeat.OID)
                    selFeat = enumFeat.Next
                Loop
0 Kudos