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

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


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 1: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")
            'Return
        End If

        Dim dtAdresEdit As New DataTable()

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


        For ColCount As Integer = 0 To fLayer

            dtAdresEdit.Columns.Add("Postcode")
            dtAdresEdit.Columns.Add("Huisnummer")
            dtAdresEdit.Columns.Add("Toevoeging")

        Next

        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

            dtAdresEdit.Rows.Add(dr)
        Next

        frmEditSwungtblACN.DataGridViewEditSwungtblACN.DataSource = dtAdresEdit

        frmEditSwungtblACN.Show()