我有一个DataSet,它包含我的WCF函数返回的值,如下所示:
DataSet ds = IserviceClient.FunctionMe(dcClient, dcBook);
#region show to dgv_item
DataTable dt1 = ds.Tables[0];
DataRow dr1;
int rc = dt1.Rows.Count;
clsMessageBoxes.ShowInfo(rc.ToString()); // Here show the number of row, so far the row is show the right value
//from here how to pass the row in that datatable to my datagridview? i
for (int i = 0; i < rc; i++)
{
dr1 = dt1.Rows[i];
dgv_item.Rows.Add();
dgv_item.Rows[i].Cells["dgvc_no"].Value = dr1["cnNo"].ToString();
dgv_item.Rows[i].Cells["dgvc_ID"].Value = dr1["cnID"].ToString();
dgv_item.Rows[i].Cells["dgvc_Name"].Value = dr1["cnName"].ToString();
}
使用它,我收到错误
当控件是数据绑定时,无法以编程方式将行添加到datagridview的rows集合
为什么我会这样做,我该如何解决?