2012-03-05 70 views
0

我試圖在winform應用中實現DataBinding。綁定到文本控件到目前爲止工作得很好。 DevExpress的DateEditLookUpEdit控件是我的麻煩來臨。DataBinding不會讓我改變值

此語句按預期工作:

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; } 
} 

回答

2

乍一看,我會說這是因爲CountyIDNullable

看看下面的article