【问题标题】:DataBinding won't let me change the valueDataBinding 不允许我更改值
【发布时间】:2012-03-23 08:16:44
【问题描述】:

我正在尝试在 winform 应用程序中实现 DataBinding。到目前为止,绑定到文本控件工作正常。我的麻烦在于 DevExpress 的 DateEditLookUpEdit 控件。

此语句按预期工作:

lkuState.DataBindings.Add("EditValue", Address, "StateID");

但是这个没有:

lkuCounty.DataBindings.Add("EditValue", Address, "County.CountyID");

我所说的按预期工作的意思是,第一条语句用适当的值填充控件并让我更改该值以进行保存。
第二条语句用适当的值填充控件,但不允许我使用控件更改该值。

对于DateEdit 控件,我对这个语句有同样的问题:

uxStartDate.DataBindings.Add("EditValue", WorkerHistory, "StartDate");

我是数据绑定的新手,很容易犯一个简单的错误,但如果我能够弄清楚是什么,我就明白了。非常感谢您的帮助。

这里是我的AddressCounty 对象供参考:

public class Address
{
    public int AddressID { get; set; }

    public string AddressLine1 { get; set; }

    public string AddressLine2 { get; set; }

    public string AddressLine3 { get; set; }

    public string City { get; set; }

    public string Zip { get; set; }

    public string ZipPlus { get; set; }

    public string DirectionsTo { get; set; }

    public string InfoRecipient { get; set; }

    public County County { get; set; }

    public string StateID { get; set; }

    public KeyValuePair<char, string> AddressType { get; set; }

    public string DisplayString { get { return ToString(); } }

    public override string ToString()
    {
        return String.Format("{0}, {1}, {2} {3}", AddressLine1, City, StateID, Zip);
    }
}
public class County
{
    public short? CountyID { get; set; }

    public string CountyName { get; set; }
}

【问题讨论】:

    标签: c# winforms data-binding devexpress


    【解决方案1】:
    【解决方案2】:

    乍一看,我会说这是因为CountyIDNullable

    看看下面的article

    【讨论】:

      猜你喜欢
      • 2017-06-19
      • 1970-01-01
      • 1970-01-01
      • 2019-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-06
      相关资源
      最近更新 更多