我在下面的链接中检查了问题: This causes two bindings in the collection to bind to the same property. Parameter name: binding error in c#?
我按照给出的答案。错误消失但有一个新问题:
有一个DGV,当我点击它的单元格时,一些文本框绑定到所选行。当我点击之后的其他行时,它会清除DGV中的第一行。
代码:
this.SupportPersonnelIDtxt.DataBindings.Clear();
this.SupportCallingPersontxt.DataBindings.Clear();
this.SupportCustomerProductIDtxt.DataBindings.Clear();
this.SupportIssuetxt.DataBindings.Clear();
this.SupportServicetxt.DataBindings.Clear();
this.SupportResulttxt.DataBindings.Clear();
this.SupportDescriptiontxt.DataBindings.Clear();
this.SupportdatePicker.DataBindings.Clear();
this.SupportPersonnelIDtxt.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "Operator", true));
this.SupportCallingPersontxt.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "CallingPerson", true));
this.SupportCustomerProductIDtxt.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "Product", true));
this.SupportIssuetxt.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "Issue", true));
this.SupportServicetxt.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "Service", true));
this.SupportResulttxt.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "Description", true));
this.SupportDescriptiontxt.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "Result", true));
this.SupportdatePicker.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.supportTblBindingSource, "Date", true));
答案 0 :(得分:0)
我尝试了更好的方法。这就是我用DGV中所选行的值填充文本框的方法。
代码:
SupportPersonnelIDtxt.Text = dataGridView7.Rows[e.RowIndex].Cells[0].Value.ToString();