Member Avatar

I have tried many methods to save my datagridview contents to a file
but with no luck
does anybody have a good method for xml to datagridview, datagridview to Xml,
or any other methods to read/write a datagridview

i did it once and it worked fine
i remember i did row1:cell;cell;cell|row2:cell;cell;cell ...
you can choose any other delimiter
than use the split method to reload the text into the dgrid.

Member Avatar

oh so for each row you create a line (of string),

ps: I created this with the information for saving:

Dim content As String
        For I As Integer = 0 To DataGridView1.Rows.Count
            For J As Integer = 0 To DataGridView1.ColumnCount
                content = content & ";" & DataGridView1.Rows(I).Cells(J).Value.ToString
            content = content & vbCrLf

use for each .. it's better i think
note: be careful with the delimiters .. only use chars you don't use in the cell contents like "#" or "|" or maybe "^"

Be a part of the DaniWeb community

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