将值读取到Access数据库中的列表框 [英] Reading Values to Listbox in Acccess Database
问题描述
目前,我有一个带有文本框,两个按钮,一个列表框和一个标签的表单
当前程序通过数据库在文本框中查找匹配的字符串.如果从数据库的文本框中找到了指定的字符串或单词,则将相应的匹配项添加到列表框中.如何将左侧或右侧的值添加到列表框?
例如:
名:中间名:姓:
约翰·山姆·麦克米林
戴夫·丹尼斯·联想
输出:
约翰·山姆·麦克米林
戴夫·丹尼斯·联想
对于我来说,更重要的是如何实时过滤或查询.
是否有可能在文本框中查询字符串的第一个和第二个值,以返回数据库中可能的匹配项,然后找到匹配项,以便它不搜索数据库中的所有值,而是仅搜索满足前两个值的那些值值?
例如:
文本框值=火山
来自数据库的结果=
vo
卷
volc
火山
然后:
如果结果= textbox1.text,则
listbox1.items.add(results.getstring)
预先谢谢您!
Currently I have a form with a textbox, two buttons, a listbox and one label
The current program looks through the database for a matching string in the textbox. If the specified string or word is found from the textbox in the database the corresponding match is added to the listbox. How can I add the value beside it either left or right to the listbox also?
for example in short:
First name: Middle name: Last name:
John Sam Mcmillin
Dave Denis Lenovo
output:
John Sam Mcmillin
Dave Denis Lenovo
Even more important to me at this point is how I can filter or query in real time.
is it possible to query the first and second value for the string in the textbox to return the possible matches in the database to then find the matches so that it does not search all the values in the database but only the ones that meet the first two values?
example:
textbox value = Volcano
results from database =
vo
vol
volc
volcano
then:
if results = textbox1.text then
listbox1.items.add(results.getstring)
Thank you in advance!!
推荐答案
您需要选择所有三个值,然后将它们与空格一起添加,然后一次将它们全部添加到item.Add调用中.您还可以创建一个用于保存项目的类,并具有所有三个名称的属性,以及一个ToString方法,该方法返回格式化的名称,并使所有项目成为其中之一.
You need to select all three values then add them together with spaces and add them all at once in the items.Add call. You could also create a class that holds items, and has properties for all three names, and a ToString method that returns the formatted name, and make all of your items one of those.
这篇关于将值读取到Access数据库中的列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!