Windows 应用程序 DataGrid数据绑定显示中文列名

 

可以的private void SetDgTableStyle()
{//设置dgDisplay的显示格式,将英文格式转换成中文列名
//fldVehicleNum, fldMonthBillNum, fldVehicleType, fldStartDate, fldEndDate
DataGridTableStyle dgStyle = new DataGridTableStyle();
dgStyle.MappingName =this.dtFreevihecle.TableName ;

DataGridColumnStyle fldVehicleNum=new DataGridTextBoxColumn();
fldVehicleNum.MappingName = "fldVehicleNum";
fldVehicleNum.HeaderText = "车编号";
fldVehicleNum.Width = 100;
dgStyle.GridColumnStyles.Add(fldVehicleNum);

DataGridColumnStyle fldMonthBillNum=new DataGridTextBoxColumn();
fldMonthBillNum.MappingName = "fldMonthBillNum";
fldMonthBillNum.HeaderText = "月票号";
fldMonthBillNum.Width = 100;
dgStyle.GridColumnStyles.Add(fldMonthBillNum);

DataGridColumnStyle fldVehicleType=new DataGridTextBoxColumn();
fldVehicleType.MappingName = "fldVehicleType";
fldVehicleType.HeaderText = "免费类型";
fldVehicleType.Width = 100;
dgStyle.GridColumnStyles.Add(fldVehicleType);

DataGridColumnStyle fldVehicleTypePriceID=new DataGridTextBoxColumn();
fldVehicleTypePriceID.MappingName = "fldVehicleTypePriceID";
fldVehicleTypePriceID.HeaderText = "车价类型";
fldVehicleTypePriceID.Width = 100;
dgStyle.GridColumnStyles.Add(fldVehicleTypePriceID);

DataGridColumnStyle fldStartDate=new DataGridTextBoxColumn();
fldStartDate.MappingName = "fldStartDate";
fldStartDate.HeaderText = "开始时间";
fldStartDate.Width = 100;
dgStyle.GridColumnStyles.Add(fldStartDate);

DataGridColumnStyle fldEndDate=new DataGridTextBoxColumn();
fldEndDate.MappingName = "fldEndDate";
fldEndDate.HeaderText = "结束时间";
fldEndDate.Width = 100;
dgStyle.GridColumnStyles.Add(fldEndDate);
this.dgList.TableStyles.Clear();
this.dgList.TableStyles.Add (dgStyle);
}

阅读更多
文章标签: datagrid windows
个人分类: .Net
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭