我有一个来自wpf工具包的autocompleteox。 我想从数据库的建议,所以我绑定一个数据库列,从数据库填充。使用此代码:
Public Function GetPatients() As DataTable
conn.Open()
If ds_all.Tables.Contains("patients") Then
ds_all.Tables.Remove("patients")
End If
cmd = New OdbcCommand("select * from tbl_patients", conn)
Dim tble As New DataTable("patients")
ds_all.Tables.Add(tble)
da_all = New OdbcDataAdapter(cmd)
da_all.Fill(ds_all.Tables("patients"))
cmd.Dispose()
conn.Close()
Return ds_all.Tables("patients")
End Function
AutoCompleteBox1.itemssource= GetPatients().columns(0).tostring()
xaml是这样的:
<my1:AutoCompleteBox Height="27" HorizontalAlignment="Left" Margin="316,30,0,0" Name="AutoCompleteBox1" VerticalAlignment="Top" Width="172" BorderThickness="2" IsDropDownOpen="True" IsTextCompletionEnabled="True" FilterMode="StartsWith" BorderBrush="{x:Null}">
</my1:AutoCompleteBox>
它不起作用。没有任何建议。
我该怎么办?