This project is read-only.

How to fill a datagridview with a selection of part of a layer: need codesnippets

Jul 23, 2013 at 3:14 AM
Anyone know how to convert a selection from a layer to a dataset/datatable and then into adatagridview?
Jul 27, 2013 at 8:33 PM

when the user makes a selection on a particular layer i want to capture this selection in a datatable for showing it in a datagrid.... i cant figure it out well.... anyone?
Jul 28, 2013 at 2:45 PM
This worked for me but now i want to automatic copy all columns in the layer to the datatable anyone?
        ' Make sure layer is loaded
        Dim fLayer As IFeatureLayer = TryCast(GetLayer(LayerName), IFeatureLayer)

        If fLayer Is Nothing Then
            'need to load a layer to work with
            System.Windows.Forms.MessageBox.Show("Selecteer eerst adressen")
        End If

        Dim dtAdresEdit As New DataTable()

        Dim lstFeatures As List(Of IFeature) = fLayer.Selection.ToFeatureList()

        For ColCount As Integer = 0 To fLayer



        For Each ftr As IFeature In lstFeatures
            Dim Postcode As String = ftr.DataRow("Postcode").ToString()
            Dim Huisnummer As String = ftr.DataRow("Huisnummer").ToString()
            Dim Toevoeging As String = ftr.DataRow("Toevoeging").ToString()

            Dim dr As DataRow = dtAdresEdit.NewRow
            dr("Postcode") = Postcode
            dr("Huisnummer") = Huisnummer
            dr("Toevoeging") = Toevoeging


        frmEditSwungtblACN.DataGridViewEditSwungtblACN.DataSource = dtAdresEdit