我正在尝试自动完成源文本框,但出现此错误:
Exception引发的异常:System.Windows.Forms.dll中的“ System.InvalidCastException”(“未注册的接口未能找到IID的代理注册:{EAC04BC0-3791-11D2-BB95-0060977B464C。”)System.InvalidCastException
所有这些都在更改AutoCompleteMode时发生,我不知道为什么,该代码以前运行良好,但是现在我遇到了这个错误。
这是我的代码:
Conn.Open()
Dim cmd As New OleDbCommand("SELECT MaterialName FROM Materials where SANF = @SANF", Conn)
cmd.Parameters.AddWithValue("@SANF", "fix_parts")
Dim ds As New DataSet
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds, "list")
Dim col As New AutoCompleteStringCollection
Dim i As Integer
MsgBox(ds.Tables(0).Rows.Count)
For i = 0 To ds.Tables(0).Rows.Count - 1
col.Add(ds.Tables(0).Rows(i)("MaterialName").ToString())
Next
Conn.Close()
TxTMaterialName.AutoCompleteSource = AutoCompleteSource.CustomSource
TxTMaterialName.AutoCompleteCustomSource = col
TxTMaterialName.AutoCompleteMode = AutoCompleteMode.Suggest
我在这里遇到错误:
TxTMaterialName.AutoCompleteMode = AutoCompleteMode.Suggest