我有一个帐户编号列表,我想在用户在文本框中输入时显示。我得到了InvalidCastException was unhandled
。
我的代码示例:
private void TextBoxAutoComplete()
{
AutoCompleteStringCollection myCollection = new AutoCompleteStringCollection();
List<AccountsVOL> avo = acctBAL.searchByAccountNOBAL(txtAccountNo.Text);
if (avo.Count > 0)
{
foreach (AccountsVOL vo in avo)
{
myCollection.Add(vo.AccountNumber);
}
txtAccountNo.AutoCompleteCustomSource = myCollection;
}
}
堆栈追踪:
在System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid&amp; clsid,Object punkOuter,Int32 context,Guid&amp; iid)at System.Windows.Forms.StringSource..ctor(String [] strings)at System.Windows.Forms.TextBox.SetAutoComplete(布尔值重置)at System.Windows.Forms.TextBox.set_AutoCompleteCustomSource(AutoCompleteStringColl挠度 值)