Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#WindowsForms数据绑定不会更新所有字段_C#_Winforms_Data Binding - Fatal编程技术网

c#WindowsForms数据绑定不会更新所有字段

c#WindowsForms数据绑定不会更新所有字段,c#,winforms,data-binding,C#,Winforms,Data Binding,有一个windows窗体应用程序,其中有几个字段应通过数据绑定进行更新。 所有字段将包含在“此”部分中,所有字段将显示在所附标签中,但不显示在[BaustelleName]中 要使用的源是: public string BaustelleName { get { return string.IsNullOrEmpty(this.sName) ? null : sName; } set { sName =

有一个windows窗体应用程序,其中有几个字段应通过数据绑定进行更新。 所有字段将包含在“此”部分中,所有字段将显示在所附标签中,但不显示在[BaustelleName]中

要使用的源是:

    public string BaustelleName
    {
        get { return string.IsNullOrEmpty(this.sName) ? null : sName; }
        set
        {
            sName = value;
            InvokePropertyChanged(new PropertyChangedEventArgs("BaustelleName"));
        }
    }

    public string BaustelleZusatz
    {
        get { return string.IsNullOrEmpty(this.sZusatz) ? null : sZusatz; }
        set
        {
            sZusatz = value;
            InvokePropertyChanged(new PropertyChangedEventArgs("BaustelleZusatz"));
        }
    }

。。。其他字段也一样。 我发现,[BaustelleName]的getter从未被调用,而所有其他的getter在每次调用[InvokePropertyChanged]时都被调用


可能有什么问题?

您将绑定添加到错误的标签:您将其添加到lbl_ArdKunde而不是lbl_AdrBaustelle

//lbl_AdrBaustelle_Zl1.Text = adr.VornameName; ---------------------------------------
    parent.lbl_AdrBaustelle_Zl1.DataBindings.Clear();
    bnd = new Binding("Text", this, "BaustelleName");
    parent.lbl_AdrKunde_Zl1.DataBindings.Add(bnd);

@你说得对;非常感谢,并为这个愚蠢的问题道歉。正如我们在德语中所说:“有时你看不到眼前的手”
    public void InvokePropertyChanged(PropertyChangedEventArgs e)
    {
        PropertyChanged?.Invoke(this, e);
    }
//lbl_AdrBaustelle_Zl1.Text = adr.VornameName; ---------------------------------------
    parent.lbl_AdrBaustelle_Zl1.DataBindings.Clear();
    bnd = new Binding("Text", this, "BaustelleName");
    parent.lbl_AdrKunde_Zl1.DataBindings.Add(bnd);