进行手持设备wince开发中DataGrid的样式设置(宽度)
2020-12-13 01:37
标签:style c class blog code java 进行手持设备wince开发中DataGrid的样式设置(宽度),搜素材,soscw.com 进行手持设备wince开发中DataGrid的样式设置(宽度) 标签:style c class blog code java 原文地址:http://www.cnblogs.com/zfrblog/p/3744931.html private void SelectGoodsForm_Load(object sender, EventArgs e)
{
//定义 DataGrid样式
DataGridTableStyle dataGridStyle = null;
dataGridStyle = new DataGridTableStyle();
this.goodsGrid.DataSource = createDataTable();
//清楚之前的DataGrid样式
this.goodsGrid.TableStyles.Clear();
//添加新样式
this.goodsGrid.TableStyles.Add(dataGridStyle);
//定义DataGrid列样式
GridColumnStylesCollection dataGridColStyle = this.goodsGrid.TableStyles[0].GridColumnStyles;
//设置DataGrid列宽度
dataGridColStyle[0].Width = 110;
dataGridColStyle[1].Width = 60;
dataGridColStyle[2].Width = 40;
dataGridColStyle[3].Width = 68;
dataGridColStyle[4].Width = 0;
dataGridColStyle[5].Width = 0;
dataGridColStyle[6].Width = 0;
//设置列头显示的文本
dataGridColStyle[0].HeaderText = "物资名称";
dataGridColStyle[1].HeaderText = "型号";
dataGridColStyle[2].HeaderText = "单位";
dataGridColStyle[3].HeaderText = "物资类型";
dataGridColStyle[4].HeaderText = "物资ID";
dataGridColStyle[5].HeaderText = "物资编号";
dataGridColStyle[6].HeaderText = "物资类型ID";
}
//为DataGrid提供数据的DataTable
private DataTable createDataTable() {
DataTable dt = new DataTable();
DataColumn col = new DataColumn();
col.Caption = "物资名称";
col.ColumnName = "GoodsName";
dt.Columns.Add(col);
col = new DataColumn();
col.Caption = "型号";
col.ColumnName = "GoodsType";
dt.Columns.Add(col);
col = new DataColumn();
col.Caption = "单位";
col.ColumnName = "OutCode";
dt.Columns.Add(col);
col = new DataColumn();
col.Caption = "物资类型";
col.ColumnName = "ItemTypeName";
dt.Columns.Add(col);
col = new DataColumn();
col.Caption = "物资ID";
col.ColumnName = "GoodsId";
dt.Columns.Add(col);
col = new DataColumn();
col.Caption = "物资编号";
col.ColumnName = "GoodsCode";
dt.Columns.Add(col);
col = new DataColumn();
col.Caption = "物资类型ID";
col.ColumnName = "ItemType";
dt.Columns.Add(col);
return dt;
}
//获取DataGrid中当前选中行的第一列中的值
this.goodsGrid[this.goodsGrid.CurrentRowIndex, 0].ToString();
上一篇:HTML条件注释用法诠释
下一篇:PHP5中魔术方法
文章标题:进行手持设备wince开发中DataGrid的样式设置(宽度)
文章链接:http://soscw.com/essay/23930.html