Torna al Thread
Public Class Form1
Private Sub SaveGridDataInFile(ByRef fName As String)
Try
Dim objWriter As New System.IO.StreamWriter(fName, True)
For iRow As Integer = 0 To Me.DataGridView1.RowCount - 1
objWriter.WriteLine(Me.DataGridView1.Item(0, iRow).Value & ";")
Next
objWriter.Close()
MsgBox("Text written to file")
Catch e As Exception
MessageBox.Show("Error occured while writing to the file." + e.ToString())
Finally
FileClose(1)
End Try
End Sub
Private Sub PopulateDataGridView()
DataGridView1.ColumnCount = 2
With DataGridView1
.Columns(0).Name = "Number"
.Columns(1).Name = "Item"
End With
For iRow As Integer = 0 To 236000 - 1
Dim row0 As String() = {iRow, "Item: " & iRow}
Me.DataGridView1.Rows.Add(row0)
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PopulateDataGridView()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SaveGridDataInFile("C:\exportDGV.csv")
End Sub
End Class