private void SetDataGridStylesFromNet(string strFlag, DataTable dtableTemp, DataGridView dataGridView)
{
if (strFlag == "老化类")
{//商品信息
int[] iArrayWidth = {180,100,200,80,60,
150,150,150,150
};
string[] strArrayText = { "条形码","产品代码","产品名称","规格型号","单位"
,"开始时间","结束时间","总耗时间","操作人"
};
string[] strArrayZiduanMapping = { "FMainBarCode","FNumber","ItemName","FModel","FUnitName"
,"FStartTime","FEndTime","IntervalTime","UserName"
};
//将DataTable绑定到DataView中
dataGridView.Columns.Clear();
dataGridView.AutoGenerateColumns = false;
//绑定DataView到dataGridView上
dataGridView.DataSource = dtableTemp;
for (int i = 0; i < iArrayWidth.Length; i++)
{
DataGridViewTextBoxColumn dataGridViewClolumnTemp = new DataGridViewTextBoxColumn();
dataGridViewClolumnTemp.DataPropertyName = strArrayZiduanMapping[i];
dataGridViewClolumnTemp.HeaderText = strArrayText[i];
dataGridViewClolumnTemp.Width = iArrayWidth[i];
dataGridView.Columns.Add(dataGridViewClolumnTemp);//最后一定要添加进去
}
return;
}
}