解釋
protected DataTable CreateTable(ArrayList arrList
// reader可以從ExecuteReader獲得
{
// DataTable的名字
DataTable dt = new DataTable(
//給DataTable定列名
for (int i =
{
DataColumn dtColumn = new DataColumn();
dtColumn
dt
}
//往DataTable裡加行
DataRow dtRow;
while (reader
{
dtRow = dt
for (int i =
{
try
{
dtRow[(string)arrList[i]] = reader
}
catch
{
dtRow[(string)arrList[i]] = System
}
}
dt
}
return dt;
}
DataTable m_listViewInfo = CreateTable(集合名
//將DataTable綁定到DataView中
DataView dvListViewInfo = new DataView(m_listViewInfo);
dataGridView
//取消dataGridView
dataGridView
//綁定DataView到dataGridView上
dataGridView
DataGridViewTextBoxColumn dtcTimeStamp = new DataGridViewTextBoxColumn();
dtcTimeStamp
dataGridView
From:http://tw.wingwit.com/Article/program/net/201311/11429.html