如何使TextBox成为Google桌面应用程序+ VB.net中的搜索选项 [英] How to Make TextBox as Search Option Just Like Google in Desktop Application + VB.net

查看:58
本文介绍了如何使TextBox成为Google桌面应用程序+ VB.net中的搜索选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我想使TextBox成为动态搜索,只需输入一些字符串,然后从数据库中输入相关的字符串,然后我就可以选择该字符串并将其显示在TextBox中

就像在Google中,甚至在您管中一样,网站发生了

所以请救救我,紧急

在Advance中感谢

Hello Friends,

I Wanted To Make TextBox as Dynamic Search, Just I Type Some String and the relevant string Come from the Database,and I Can Select That String And It Appears in TextBox

Just Like In Google OR Even In You Tube Sites happens

So Please Help Me , It''s Urgent

Thanks in Advance

推荐答案

如果您使用LinQ,这相对简单.如果您具有人物"对象列表,并且希望找到名称中带有"an"短语的人物,则可以执行以下操作

It is relatively simple if you use LinQ. If you have a List of Person objects and you wish to find the people with the phrase ''an'' in their name you would do something like this

class Person
   {
       public string Name { get; set; }
       public int Age { get; set; }
   }

List<Person> SelectItems(List<Person> people, string searchText)
       {
           return (from person in people where person.Name.Contains(searchText) select person).ToList();
       }



如果您尝试从数据库中获取结果,则需要在查询中使用LIKE子句,例如



If you are trying to get the results from a database, then you need to use a LIKE clause in the query like this

SqlCommand cmd = new SqlCommand("SELECT Name, Age FROM People WHERE Name LIKE @SearchString", con);
                cmd.Parameters.AddWithValue("@SearchString", "%" + searchString + "%");



希望这会有所帮助

糟糕,您刚刚看到的问题是有关VB的,但您应该了解一下.

代码转换
将C#转换为VB.NET [



Hope this helps

Oops, just saw your question was about VB, but you should get the picture.

Code conversion
Convert C# to VB.NET[^]


这是解决方案....它很好仔细地经过它.

http://www.vbdotnetheaven.com/uploadfile/mahesh/auto-complete -textbox-in-vb-net/ [
Here is the solution....it great go through it carefully.

http://www.vbdotnetheaven.com/uploadfile/mahesh/auto-complete-textbox-in-vb-net/[^]


这篇关于如何使TextBox成为Google桌面应用程序+ VB.net中的搜索选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆