Gridview与winforms中的文本框和搜索按钮 [英] Gridview with textbox and search button in winforms

查看:85
本文介绍了Gridview与winforms中的文本框和搜索按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个学生注册表格,我需要一个带有文本框的gridview和gridview上方的按钮,以通过studentID搜索学生。我是C#的初学者,我不知道该怎么做以及gridview和searchbox需要哪些代码。请帮助我

I have a register form for students and I need to have a gridview with a textbox and a button above the gridview to search students by studentID. I am beginner in C# and I don`t know what should I do and which codes I need for gridview and searchbox.please help me

推荐答案

至少有几种方法实现这个目标:

1)使用存储过程

如何:执行返回行的存储过程 [ ^ ]

如何:使用带有输入和输出参数的存储过程执行查询 [ ^ ]



2)使用过滤器 [ ^ ]用于绑定源

DataGridView BindingSource.Filter Windows Forms Sample [ ^ ]



3)将Dropdown添加到DataGridView的标题

为DataGridView列构建下拉列表标题单元格 [ ^ ]



4)使用 Linq To Dataset [ ^ ]

查询数据集(LINQ to DataSet) [ ^ ]



5)等



尝试一下,当你回到这里坚持提问详细问题。
There's at least few ways to achieve that:
1) using stored procedure
How to: Execute a Stored Procedure that Returns Rows[^]
How to: Execute a Query Using a Stored Procedure with In and Out Parameters[^]

2) using Filter[^] for binding source
DataGridView BindingSource.Filter Windows Forms Sample[^]

3) adding Dropdown to DataGridView's Headers
Building a Drop-Down Filter List for a DataGridView Column Header Cell [^]

4) using Linq To Dataset[^]
Querying DataSets (LINQ to DataSet)[^]

5) etc.

Try something and get back here when you get stuck to ask detailed question.


<pre>con.Open();<br />
da = new OleDbDataAdapter(" select *from tablename where studentID ='" + textbox1.Text + "'", con);<br />
            DataSet ds = new DataSet();<br />
            da.Fill(ds, "tablename");<br />
            dataGridView1.DataSource = ds.Tables[0];<br />
            ds.Tables.Clear();<br />
            con.close();</pre>


这篇关于Gridview与winforms中的文本框和搜索按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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