Hi there
I've got a datagridview (called: Device_LabelsDataGridView) which has a mix of visible and invisible columns. I am wanting to export a specific two columns titled 'Location" (which is hidden) and "Data" (which is visible) but miss out the middle column called "Description". I haven't an issue exporting all the data including the hidden columns and at the minute, the code provided further down exports my data like this (with the commas just like they are):
Location,Description,Data Location,Description,Data Location,Description,Data Continued…..
Location,Data Location,Data Location,Data Continued…..
Below is the code I have tried to use, but can't get what I want.
Dim writer As StreamWriter = New StreamWriter("C:\GridExport.txt")
If (DeviceLabels.Device_LabelsDataGridView.Rows.Count > 0) Then
For Each col As DataGridViewColumn In DeviceLabels.Device_LabelsDataGridView.Columns
Next
End If
For Each row As DataGridViewRow In DeviceLabels.Device_LabelsDataGridView.Rows
'If Not omitIndices.Contains(row.Index) Then
For Each cell As DataGridViewCell In row.Cells
If (cell.OwningColumn.Index = (DeviceLabels.Device_LabelsDataGridView.Columns.Count - 1)) Then
If (Not (cell.Value) Is Nothing) Then
writer.WriteLine(cell.Value.ToString)
Else
writer.WriteLine("")
End If
ElseIf (Not (cell.Value) Is Nothing) Then
writer.Write(String.Concat(cell.Value.ToString, ","))
Else
writer.Write(String.Concat("", ","))
End If
Next
'End If
Next
writer.Close()
End SubCan someone help? I don't have much hair left!!! I am a newcomer to VB and have 0 experience, nor can I find any relevant examples. I need text files too, so no other format can be used. The program I am creating is an EEPROM programmer- once this text export works I can work on the next half of my program- sending the files to my EEPROM handler.