How to retrieve all fieldnames of a shape into a combobox..?

Sep 15, 2012 at 8:25 PM

Hellor readers, this is my question

How to retrieve all fieldnames of a shape into a combobox..?

 I found a possible solution at the 7th tutorial doc Shape file label operations~ Tutorial (7)

But

I used the code and did the NET4.0 instruction, but this isnt working yet, it generates 2 errors, one in each sub.... 1) Access..... through qualifying expression will not be evaluated AND 2) data is not a member of Dotspatial.Data.Featureset.... 

Any ideas to give me some direction......... i will first try to solve the 2nd one..... It feels it may have to do with most examples available being outdated but even that I am not sure of....

Private Sub CheckedListBoxGEBOUWENshape_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBoxGEBOUWENshape.SelectedIndexChanged

        'Clear the existing layers from the map control
        If (myVenster.Layers.Count > 0) Then
            myVenster.Layers.Clear()
        End If
        'Clear the exisiting items from the combobox
        ComboBoxAdressenAttributen.Items.Clear()

        Dim fileDialog As New OpenFileDialog()
        FileDialog.Filter = "Shapefiles|*.shp"
        If fileDialog.ShowDialog = DialogResult.OK Then
            'add layer to first map

            Dim featureSet1 As New FeatureSet
            featureSet1.Open(fileDialog.FileName)

            'FillColumnNames method is used to get all the attribute column names 
            'Based on the names combobox will be populated
            Fillcolumnnames(featureSet1)
            featureSet1.Reproject(myVenster.Projection)
            myVenster.Layers.Add(featureSet1)
            myVenster.ZoomToMaxExtent()
        End If
    End Sub

    Private Sub FillColumnNames(ByVal ByValfeatureSet As IFeatureSet)
        For Each column As DataColumn In FeatureSet.DataTable.Columns
            cmbFiledName.Items.Add(column.ColumnName)
        Next
    End Sub

Sep 19, 2012 at 4:27 AM

Well found the solution ....  I would have posted it here but better go to the dotspatial site...  forum

 

thx..