0

我无法清除 DataTable Bind to the (cnsmNm) datagridviewCombobox 列。在新按钮上单击我正在清除数据

 dtCnsmbl = dsCnsmspplr.Tables[0]; 
            dtCnsmbl.Rows.Clear();
            cnsmNm.DataSource = dtCnsmbl;
            cnsmNm.DisplayMember = "cnsm_Name";
            cnsmNm.ValueMember = "cnsm_Id";

在文本框验证(DataGridView 外部)上,我将数据绑定到 Datagridview ComboBox 列

                dtqttndtls = dssplrdtls.Tables[3];
                DataTable dtmerge = new DataTable();
                dtmerge.Columns.Add("cnsm_Id", typeof(Int32));
                dtmerge.Columns.Add("cnsm_Name");
                foreach (DataRow drmrg in dtqttndtls.Rows)
                {
                    DataRow drnew = dtmerge.NewRow();
                    drnew["cnsm_Id"] = drmrg["cnsm_Id"];
                    drnew["cnsm_Name"] = drmrg["cnsm_Name"];
                    dtmerge.Rows.Add(drnew);
                }
                dtCnsmbl.Merge(dtmerge);
                cnsmNm.DataSource = dtCnsmbl;
                cnsmNm.DisplayMember = "cnsm_Name";
                cnsmNm.ValueMember = "cnsm_Id";

填充 Datagridviewcombobox 列后,我无法清除 DataTable。我是 Datagridview 的新手。

4

1 回答 1

1

嗨,我认为不是这个

        dtCnsmbl = dsCnsmspplr.Tables[0]; 
        dtCnsmbl.Rows.Clear();
        cnsmNm.DataSource = dtCnsmbl;
        cnsmNm.DisplayMember = "cnsm_Name";
        cnsmNm.ValueMember = "cnsm_Id";

写这个

       DataTable newdata = dsCnsmspplr.Tables[0].Clone();
       cnsmNm.DataSource = newdata;
        cnsmNm.DisplayMember = "cnsm_Name";
        cnsmNm.ValueMember = "cnsm_Id";
于 2013-05-05T10:41:20.590 回答