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
        gridtable.Columns.Add(gridtable_column1)
        gridtable.Columns.Add(gridtable_column2)
        gridtable.Columns.Add(gridtable_column3)
        gridtable.Columns.Add(gridtable_column4)
        gridtable.Columns.Add(gridtable_column5)

        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.Rows.Add(table_row)
            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
        ds.ReadXml(xmlFile)
        DataGridView1.DataSource = ds.Tables(0)

I figured it out

Member Avatar for Unhnd_Exception

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, networking, learning, and sharing knowledge.