如何在不使用数据库的情况下在 VB.NET 中的 DataGridView 中显示数组?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28780673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show array in DataGridView in VB.NET without using Database?
提问by Dipankar Nalui
I want to show Array1 in column1 in Table format. Array2 in Column2. Array3 in Column3. No need Database connection. Just i'll pass 4 arrays in datagridview or any table and it will display the contents of array. array1=column1, array2=column2 and so on....
我想以表格格式在 column1 中显示 Array1。列 2 中的数组 2。列 3 中的数组 3。不需要数据库连接。只是我将在 datagridview 或任何表中传递 4 个数组,它将显示数组的内容。array1=column1,array2=column2 等等......
回答by Sanu
Just using a For Loopu can do it easily.
只需使用For 循环就可以轻松完成。
For i As Integer = 0 To array1.GetUpperBound(0)
Dim x As String() = {array1(i), array2(i), array3(i), array4(i)}
DataGridView1.Rows.Add(x)
Next
Thanx.
谢谢。

