Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

New Post: Attribute table

$
0
0
Hi,
I try to create a basic GIS application with DotSpatial. One thing i want to add is a button to the attribute table of the selected layer. my layout is the basic one with the SpatialToolStrip, Map, Legend and SpatialStatusSrip.
Everything seems to work just fine when the Shapefiles are point or line, But, when i load a polygon shapefile and click the show attribute table button, my app crashes.
The same goes when i create new app and adding a button with this code:
Public Function FeatureLayerType(ByVal dsMap As DotSpatial.Controls.Map, ByVal layerindex As Integer) As String

            If Not TryCast(dsMap.Layers(layerindex), MapPointLayer) Is Nothing Then
                FeatureLayerType = "Point" 'Point Layer
            ElseIf Not TryCast(dsMap.Layers(layerindex), MapLineLayer) Is Nothing Then
                FeatureLayerType = "PolyLine"
            ElseIf Not TryCast(dsMap.Layers(layerindex), MapPolygonLayer) Is Nothing Then
                FeatureLayerType = "PolyGon"
            Else
                FeatureLayerType = "NonFeatureLayer"
            End If
            Return FeatureLayerType
        End Function

Private Sub ToolStripButtonTabelweergave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonTabelweergave.Click
            Dim ActPolyLayer As MapPolygonLayer = Nothing
            Dim ActLineLayer As MapLineLayer = Nothing
            Dim ActPointLayer As MapPointLayer = Nothing

            
            Map1.FunctionMode = FunctionMode.None

            If Map1.Layers.Count > 0 Then
                For i = 0 To Map1.Layers.Count - 1
                    If Map1.Layers(i).IsSelected = True Then
                        If FeatureLayerType(Map1, i) = "PolyGon" Then
                            ActPolyLayer = CType(Map1.Layers(i), MapPolygonLayer)
                            ActPolyLayer.ShowAttributes()
                        End If
                        If FeatureLayerType(Map1, i) = "PolyLine" Then
                            ActLineLayer = CType(Map1.Layers(i), MapLineLayer)
                            ActLineLayer.ShowAttributes()
                        End If
                        If FeatureLayerType(Map1, i) = "Point" Then
                            ActPointLayer = CType(Map1.Layers(i), MapPointLayer)
                            ActPointLayer.ShowAttributes()
                        End If

                    End If
                Next
            End If
        End Sub
Please any help on why the app crashes only when i want to view the attribute table of a polygon shapefile?
thanks!

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>