关于C1FlexGrid format属性
cfg.Cols[i].DataType = typeof(DateTime); cfg.Cols[i].Format = lisComboFormat[i];//循环读取
当控件使用DataSource时,以上代码失灵。
解决办法自己定义FlexGrid的表结构(行,列数量,列宽),然后再根据数据源循环,添加数据
//从dataTable给flexgrid单元格赋值 private static void flexGridValue(C1FlexGrid cfg) { for (int i = 0; i < cfg.Cols.Count; i++) { // cfg.Rows[0][i] = lisText[i];//列头赋值 //给每一行绑定值 for (int j = 1; j < dt.Rows.Count + 1; j++)// { if (i != 0) { cfg.Rows[j][i] = dt.Rows[j - 1][i - 1];//给单元格值 string tt = dt.Rows[j - 1][i - 1].ToString(); } } } }