代码之家  ›  专栏  ›  技术社区  ›  Scott Chamberlain

只有一个文本框使用数据绑定源进行更新

  •  0
  • Scott Chamberlain  · 技术社区  · 15 年前

    我有一堆文本框绑定到表适配器,当我填充数据表时,所有文本框中只有一个框会填充,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, "");
    

    下面是所有有效的feild配置代码,其中一个不显示任何内容。

    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();
    

    放入一个绑定源并通过它进行引导没有什么区别。

    edit——validateChildren返回true; 我不知道我改了什么,但txteducator也不再更新了。

    2 回复  |  直到 15 年前
        1
  •  0
  •   Klaus Byskov Pedersen    15 年前

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

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

    你为什么要在结尾处更新这些物体?

        2
  •  0
  •   Scott Chamberlain    15 年前

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

    推荐文章