在gridView列名称中搜索 [英] search in gridView column name

查看:41
本文介绍了在gridView列名称中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在搜索框中创建了一个文本框.

我已经创建了gridview,然后添加了数据库.

我的数据库名称是学生,

我的gridview列名称,例如

名称ID地址课程等,

数量的字段添加到gridview中.

我想在文本框中搜索特定名称.

请发送相关的教程或链接

I create one textbox the textbox as search.

already i create gridview and then added database.

my database name is student,

my gridview column name Such as

Name Id Address Course Etc.,

numbers of fields add in gridview.

i want search the specific name search in the textbox.

Please send related tutorials or links

推荐答案

在文本框中使用自动完成源.示例代码:

Use Autocompletesource in textbox. Sample code:

Dim dt As New DataTable
          Dim da As New OleDbDataAdapter("select * from Tablename", ocon)
          da.Fill(dt)
          Dim row As DataRow
          TextBox1.AutoCompleteCustomSource.Clear()
          For Each row In dt.Rows
              TextBox1.AutoCompleteCustomSource.Add(row.Item(0).ToString)
          Next


您具体要解决哪一部分的问题?您只需要遍历数据行,并将名称字段与文本框中的内容进行比较.找到匹配项"后,您便可以执行搜索所需的操作……我想这就是滚动到该行.至于匹配"是什么,您将不得不进一步解释.如果用户在文本框中输入"J",是否要所有以J开头的名称?还是所有包含J的名称?还是只有正好是J的名字?
What part of this are you having trouble with specifically? You just need to loop through the rows of data and compare the name field to whatever is in your textbox. Once you''ve found a "match" you do whatever you want the search to do...which I''d assume would be to scroll to that row. As for what a "match" is, you''d have to explain further. If a user types "J" into the textbox, do you want all names that start with J? Or all names that contain a J? Or only names that are exactly J?


这篇关于在gridView列名称中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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