如何将数组类型绑定到DataGridViewvb.net 控件数组

int[,] TABLE = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } };
DataTable dt = new DataTable();
for (int i = 0; i & TABLE.GetLength(1); i++)
dt.Columns.Add(i.ToString(), typeof(int));
for (int i = 0; i & TABLE.GetLength(0); i++)
DataRow dr = dt.NewRow();
for (int j = 0; j & TABLE.GetLength(1); j++)
dr[j] = TABLE[i, j];
dt.Rows.Add(dr);
this.dataGridView1.DataSource =
本文已收录于以下专栏:
相关文章推荐
可以把二维数组转化为DataTalbe。以下为程序实例,其中的ConvertToDataTable可以直接调用,只要根据数组类型设置不同的参数类型就可以了。     protected void Pa...
  '博客园'是一家国内的大型日化用品,生活用品生产,销售公司,它的一部分销售是放在淘宝网上进行的,在淘宝网上这家公司有多个网店,线下有系统对每个网店的销售数据通过淘宝API进行抓取保存,...
【1】结构体中含有内置数据类型的一维数组
typedef struct _testStru3
iValArrp[30];
WCHAR szChArr[30];
本人是从Java转向C#的,由于工作需要,感觉C#和Java的很多类似性,所以在使用C#的时候总喜欢套用Java的,因为他们太像了,然而今天却碰了一鼻子灰,原因就在使用二维数组上。
在Java中使用...
他的最新文章
讲师:汪剑
讲师:刘道宽
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)新浪广告共享计划>
广告共享计划
dataGridView中的数据存入一个二维数组
public string[,]
ToStringArray(DataGridView dataGridView, bool
includeColumnText)
#region 实现...
string[,] arrReturn =
int rowsCount = dataGridView.Rows.C
int colsCount = dataGridView.Columns.C
if (rowsCount & 0)
//最后一行是供输入的行时,不用读数据。
if (dataGridView.Rows[rowsCount - 1].IsNewRow)
rowsCount--;
int i = 0;
//包括列标题
if (includeColumnText)
rowsCount++;
arrReturn = new string[rowsCount, colsCount];
for (i = 0; i & colsC i++)
arrReturn[0, i] = dataGridView.Columns[i].HeaderT
arrReturn = new string[rowsCount, colsCount];
//读取单元格数据
int rowIndex = 0;
for (; i & rowsC i++, rowIndex++)
for (int j = 0; j & colsC j++)
arrReturn[i, j] =
dataGridView.Rows[rowIndex].Cells[j].Value.ToString();
return arrR
#endregion 实现
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 android 控件数组 的文章

 

随机推荐