Hi all
The following saves my dgv into a .txt file, comma separated and allows me to reload it later.
Only issue is with my checkbox columns as this code only saves a "true" and when the check box is "false" rather it leaves it empty in the .txt file.
eg...for a dgv of three checkboxes it would save:
True,,
When Column 1 = True and Column 2 and 3 = False
This then causes issues when I come to reopen my dgv later on.
Any advice?
Code:Dim Rows = (From row In DataGridView1.Rows _ Where Not DirectCast(row, DataGridViewRow).IsNewRow _ Let RowItem = String.Join(",", Array _ .ConvertAll( _ DirectCast(row, DataGridViewRow).Cells.Cast(Of DataGridViewCell).ToArray, _ Function(c As DataGridViewCell) _ If(c.Value Is Nothing, "", c.Value.ToString))) _ Select RowItem).ToArray IO.File.WriteAllLines("C:\test.txt", Rows)




Reply With Quote
