我有下面提到的方法,我將DataSource綁定到組合框控件。在將數據源綁定到組合框時的錯誤
// floorLocnList is coming from a webservice method
private void lstFloor_BindFloor(FloorLocModel[] floorLocnList)
{
this.comboBox1.DataSource = floorLocnList;
this.comboBox1.DisplayMember = "Location";
this.comboBox1.ValueMember = "FloorLoc";
}
和類這樣
[Serializable]
public class FloorLocModel
{
private int floorLoc;
private string location;
public int FloorLoc
{
get
{
return this.floorLoc;
}
set
{
this.floorLoc = value;
}
}
public string Location
{
get
{
return this.location;
}
set
{
this.location = value;
}
}
}
定義顯示錯誤值沒有在預期的範圍內伸手ValueMember
Bug Detail:
at System.Windows.Forms.ListControl._SetDataBinding(Object newDataSource, BindingMemberInfo newDisplayMember, Boolean fForceRebind)
at System.Windows.Forms.ListControl.set_ValueMember(String value)
at IdineSmart.frmLogin.lstFloor_BindFloor(FloorLocModel[] floorLocnList)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Windows.Forms.Control.TASK.Invoke()
at System.Windows.Forms.Control._InvokeAll()
at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.ListView.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.EVL.EnterModalDialog(IntPtr hwnModal)
at System.Windows.Forms.Form.ShowDialog()
at IdineSmart.frmMain.frmMain_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form._SetVisibleNotify(Boolean fVis)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.Run(Form fm)
at IdineSmart.Program.Main()
的價值分配後下降它工作正常,但我dono蘇它開始給我提出這個問題。當我調試代碼值成員顯示空字符串,即使我分配它,可能是這個問題,但它是如何發生這樣的。請幫幫我。
在此先感謝。
它綁定對象,但顯示** MobileTest.TestProxy.FloorLocModel **。你有沒有爲它做任何工作..? – 2009-10-08 09:03:44
謝謝,在我的情況下,這是解決方案 – Undercover1989 2015-11-27 12:25:01