【问题标题】:Only one text box updating with a databound source只有一个文本框使用数据绑定源进行更新
【发布时间】:2010-01-21 17:23:38
【问题描述】:

我有一堆文本框绑定到表格适配器,当我填充我的数据表时,只有一个框会填充,txtEducator(数据表中只有一行)。它们的配置完全相同。我已经调试过,数据表中的大部分字段都有数据,它只是选择只显示一个字段。 (我删除了不相关的代码和一个无效的示例)

this.txtPracticeName.DataBindings.Add("Text", this.dataStore, "CLIENT_INFO.ACCOUNT", false, DataSourceUpdateMode.OnValidation, "");
this.txtEducator.DataBindings.Add("Text", this.dataStore, "CLIENT_INFO.USERNAME", false, DataSourceUpdateMode.OnValidation, "");

这里是所有可以工作的字段的配置代码和一个没有显示任何内容的代码。

this.txtEducator = new System.Windows.Forms.TextBox();
this.txtPracticeName = new System.Windows.Forms.TextBox();
...
this.tbpPIPracticeInfo.Controls.Add(this.groupBox6);
this.tbpPIPracticeInfo.Controls.Add(this.groupBox5);
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
private System.Windows.Forms.TextBox txtEducator;
private System.Windows.Forms.TextBox txtPracticeName;
this.groupBox6.Controls.Add(this.txtEducator);
this.groupBox5.Controls.Add(this.txtPracticeName);
...
// 
// txtEducator
// 
this.txtEducator.Location = new System.Drawing.Point(8, 110);
this.txtEducator.Name = "txtEducator";
this.txtEducator.Size = new System.Drawing.Size(150, 20);
this.txtEducator.TabIndex = 19;
// 
// txtPracticeName
// 
this.txtPracticeName.Location = new System.Drawing.Point(8, 34);
this.txtPracticeName.Name = "txtPracticeName";
this.txtPracticeName.Size = new System.Drawing.Size(317, 20);
this.txtPracticeName.TabIndex = 4;

我到处找。这两个框在各方面看起来都一样,为什么我这样做时只有一个显示信息

client_infoTableAdapter.Fill(dataStore.CLIENT_INFO, txtClinicNumber.Text);
this.ValidateChildren();

放入一个绑定源并通过它引导它没有任何区别。

编辑 -- ValidateChildren 返回 true; EDIT2 -- 我不知道我改变了什么,但 txtEducator 也不再更新了。

【问题讨论】:

    标签: c# winforms data-binding


    【解决方案1】:

    我想知道这两行的作用是什么:

    this.txtEducator = new System.Windows.Forms.TextBox();
    this.txtPracticeName = new System.Windows.Forms.TextBox();
    

    你为什么要在最后更新对象?

    【讨论】:

    • 这段代码是从frmMain.designer.cs代码中复制过来的,我把我的复制和粘贴搞混了,它应该在顶部。我正在纠正它。
    【解决方案2】:

    我不知道我做了什么不同但添加绑定源再次解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-01
      • 1970-01-01
      • 2015-03-14
      • 2011-03-05
      • 1970-01-01
      • 2010-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多