I have an xml file document and I am trying to display the xml contents in a datagridview. Can I please get some help with this? what am I doing wrong? I had it working when I pull one column at a time

Dim gridtable As DataTable = New DataTable("Macros")
        Dim gridtable_column1 As DataColumn = New DataColumn("macro_ident")
        Dim gridtable_column2 As DataColumn = New DataColumn("replacement_string")
        Dim gridtable_column3 As DataColumn = New DataColumn("date_deleted")
        Dim gridtable_column4 As DataColumn = New DataColumn("macro_seq")
        Dim gridtable_column5 As DataColumn = New DataColumn("is_dirty")
        'Dim name As String

        Dim gridrow As DataGridViewRow
        Dim table_row As DataRow
        For Each gridrow In DataGridView1.Rows
            table_row = gridtable.NewRow
            table_row("macro_ident") = gridrow.Cells("macro_ident").Value
            table_row("replacement_string") = gridrow.Cells("replacement_string").Value
            table_row("date_deleted") = gridrow.Cells("date_deleted").Value
            table_row("macro_seq") = gridrow.Cells("macro_seq").Value
            table_row("is_dirty") = gridrow.Cells("is_dirty").Value

            gridtable.WriteXml(Application.StartupPath & "\Macros.xml")
        Next gridrow

        Dim xmlFile As XmlReader
        xmlFile = XmlReader.Create(Application.StartupPath & "\Macros.xml", New XmlReaderSettings())
        Dim ds As New DataSet
        DataGridView1.DataSource = ds.Tables(0)

Recommended Answers

All 2 Replies

I figured it out

Member Avatar

Happy for you. Nice job!:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.