c#_Devexpress将datatable设置为gridControl

时间:2014-11-30 17:42:46

标签: c# datatable devexpress gridcontrol devexpress-windows-ui

我想合并表中的列来显示 示例

NameEmp  |    CasualLeave    |     SickLeave     |     AnualLeave
         | auto  | Manual    |  auto  |  Manual  | auto  | manual
   epm1  |  1    |    1      |   2    |    0     |       |

我尝试在TableGridView中阅读col绘画和绘画来做到这一点,但我无法理解 所以我在dev Express,BandedGridView中使用控制网格视图来设计相同的表 当我为表BandedGridView设置源时,它只在BandedGridView中为1列设置所有dataTable

它喜欢:

dt = new DataTable();
PjControl tk = new PjControl();
dt = tk.loadTimeWork(month);
gridControl1.DataSource = dt;

public DataTable loadTimeWork(int month)
        {
            conn = new SqlDBConnection();
            conn.connection();
            DataTable dt = new DataTable("tmp");
            SqlDataAdapter da = new SqlDataAdapter();

            SqlCommand cmd = new SqlCommand("getTimeworkLeave", conn.connection());
            cmd.Parameters.Add("@month", SqlDbType.Int).Value = month;
            cmd.CommandType = CommandType.StoredProcedure;
            da.SelectCommand = cmd;
            da.Fill(dt);
            conn.connection().Close();
            return dt;
        }

和那段代码输出

    NameEmp                       |    CasualLeave    |     SickLeave     |     AnualLeave
Auto |auto   |manual| auto |...   | auto  | Manual    |  auto  |  Manual  | auto  | manual
emp1 |    1  |  1   |  2   |      |  null |     null  |        |          |       |   
     |       |      |      |      |       |           |        |          |       |  

我可以在datatable中使用foreach datarow在GridControl中逐行设置 但它花了1个foreach

如何将数据表设置为GridControl而不是更容易?比如添加标题除了标题

0 个答案:

没有答案