【问题标题】:devexpress how can add data in first row or add data to specific rowdevexpress 如何在第一行添加数据或将数据添加到特定行
【发布时间】:2020-08-24 21:48:56
【问题描述】:

我使用了devexpress gridControl,如何通过代码或默认值填充gridControl中的第一行,然后通过数据表填充其他行?或者如何将数据添加到特定行。我尝试代码,但新行转到最后一个网格控件。 看到这个链接:https://c.top4top.io/p_1697xbv9x1.png

string sql = "select sup_action_date , sup_action_code , from Suppliers_Action where supplier_id = " + txt_suppler_id.Text + "  Order by sup_action_date";

        SqlDataAdapter da = new SqlDataAdapter(sql, DB.conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataTable dt = ds.Tables[0];

        BindingSource dtbinding = new BindingSource();
        dtbinding.DataSource = dt;

        gridcontroltest.DataSource = dtbinding;
        gridviewtest.AddNewRow();
        gridviewtest.SetRowCellValue(GridControl.NewItemRowHandle, "Column Name", "test");

【问题讨论】:

    标签: gridcontrol


    【解决方案1】:
    DataTable dt = gridControl1.DataSource as DataTable;
    DataRow row = dt.NewRow();
    row["fieldname"] = 11;
    row["fieldname"] = "test";
    dt.Rows.InsertAt(row, 0);
    
    gridControl1.DataSource = dt;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-29
      • 1970-01-01
      相关资源
      最近更新 更多