日期:2014-05-18  浏览次数:21194 次

动态构造列,用dev gridcontrol绑定后,控件数据显示不出来
//构建合同入库颜色尺码表
  this.gvContactwareHouse.Columns.Clear();
  GridColumn gridCol_hide_colorid = new GridColumn();
  gridCol_hide_colorid.Caption = "colorid";//隐藏列colorid
  gridCol_hide_colorid.FieldName = "colorid";
  gridCol_hide_colorid.Name = "colorid";
  gridCol_hide_colorid.Visible = false;
  gridCol_hide_colorid.VisibleIndex = -1;
  this.gvContactwareHouse.Columns.Add(gridCol_hide_colorid);
  GridColumn gridCol_hide_sizeID = new GridColumn();
  gridCol_hide_sizeID.Caption = "SizeID";//隐藏列SizeID
  gridCol_hide_sizeID.FieldName = "SizeID";
  gridCol_hide_sizeID.Name = "SizeID";
  gridCol_hide_sizeID.Visible = false;
  gridCol_hide_sizeID.VisibleIndex = -2;
  this.gvContactwareHouse.Columns.Add(gridCol_hide_sizeID);
  GridColumn gridCol_01 = new GridColumn();
  gridCol_01.Caption = "颜色";
  gridCol_01.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
  gridCol_01.FieldName = "ColorCode";
  gridCol_01.Name = "gridColTitle";
  gridCol_01.Visible = true;
  gridCol_01.VisibleIndex = 0;
  gridCol_01.OptionsColumn.AllowShowHide = false;
  gridCol_01.OptionsColumn.ReadOnly = true;
  gridCol_01.OptionsColumn.AllowEdit = false;
  gridCol_01.OptionsColumn.AllowMove = false;
  this.gvContactwareHouse.Columns.Add(gridCol_01);
  GridColumn gridCol_02 = new GridColumn();
  gridCol_02.Caption = "尺码";
  gridCol_02.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
  gridCol_02.FieldName = "SizeCode";
  gridCol_02.Name = "gridColTitle";
  gridCol_02.Visible = true;
  gridCol_02.VisibleIndex = 1;
  gridCol_02.OptionsColumn.AllowShowHide = false;
  gridCol_02.OptionsColumn.ReadOnly = true;
  gridCol_02.OptionsColumn.AllowEdit = false;
  gridCol_02.OptionsColumn.AllowMove = false;
  this.gvContactwareHouse.Columns.Add(gridCol_02);
  int colNo = 2;//列序号,横向
  this.currentContactSaleStyleShip_ColorSizeTable = new DataTable();
  DataColumn ColorColumn = new DataColumn("ColorCode");
  this.currentContactSaleStyleShip_ColorSizeTable.Columns.Add(ColorColumn);
  DataColumn SizeColumn = new DataColumn("SizeCode");
  this.currentContactSaleStyleShip_ColorSizeTable.Columns.Add(SizeColumn);
  DataColumn coloridColumn = new DataColumn("colorid");
  this.currentContactSaleStyleShip_ColorSizeTable.Columns.Add(coloridColumn);
  DataColumn sizeidColumn = new DataColumn("SizeID");
  this.currentContactSaleStyleShip_ColorSizeTable.Columns.Add(sizeidColumn);
  foreach (Contactship ship in this.contactshiplist)//构造船期
  {
  RepositoryItemTextEdit gridColTextEdit = new RepositoryItemTextEdi