Windows 應用程式 DataGrid資料繫結顯示中文列名

yifei170發表於2006-06-20

 

可以的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);
}

相關文章