如何将datagridview的内容导出到文本文件vb.net 2010
How to export the content of a datagridview to a text file vb.net 2010
我有一个包含 1 列(客户名称)的数据网格视图,我想将其内容导出到文本文件 (c:\file.txt)。
我怎样才能做到这一点 ?
谢谢
最简单的方法是:
Dim result As String = ""
'go through all rows
For rowNumber As Integer = 0 To DataGridView1.Rows.Count - 1
'this gets just column 0 (the first column)
result += DataGridView1.Item(0, rowNumber).ToString
Next
'write out the string
File.WriteAllText("c:\file.txt", result)
我有一个包含 1 列(客户名称)的数据网格视图,我想将其内容导出到文本文件 (c:\file.txt)。 我怎样才能做到这一点 ? 谢谢
最简单的方法是:
Dim result As String = ""
'go through all rows
For rowNumber As Integer = 0 To DataGridView1.Rows.Count - 1
'this gets just column 0 (the first column)
result += DataGridView1.Item(0, rowNumber).ToString
Next
'write out the string
File.WriteAllText("c:\file.txt", result)