分类: C/C++
2008-05-30 20:56:22
private void frmLog_Load(object sender, System.EventArgs e)
{
//设置DataGrid的列宽
InitDataGridColumnHeader();
//GetResult();
}
private void InitDataGridColumnHeader()
{
DataGridTableStyle dts=new DataGridTableStyle();
//注意:必须加上这一句,否则自定义列格式无法使用
dts.MappingName=\"Table\";
hrgLog.TableStyles.Add(dts);
hrgLog.TableStyles[0].GridColumnStyles.Clear();
//========================设置表头栏位===========================
DataGridTableStyle dtsLog = new DataGridTableStyle();
DataGridTextBoxColumn colID = new DataGridTextBoxColumn();
colID.Width=80;
colID.HeaderText = \"记录序号\";
colID.MappingName = \"ID\";
hrgLog.TableStyles[0].GridColumnStyles.Add(colID);
DataGridTextBoxColumn colLog = new DataGridTextBoxColumn();
colLog.Width=200;
colLog.HeaderText = \"日志内容\";
colLog.MappingName = \"LogMessage\";
hrgLog.TableStyles[0].GridColumnStyles.Add(colLog);
DataGridTextBoxColumn colTime = new DataGridTextBoxColumn();
colTime.Width=100;
colTime.HeaderText = \"记录时间\";
colTime.MappingName = \"LogTime\";
hrgLog.TableStyles[0].GridColumnStyles.Add(colTime);
DataGridTextBoxColumn colCatalog = new DataGridTextBoxColumn();
colCatalog.Width=100;
colCatalog.HeaderText = \"日志类别\";
colCatalog.MappingName = \"LogCatalog\";
hrgLog.TableStyles[0].GridColumnStyles.Add(colCatalog);
}