在C#中搜索/过滤datagridview [英] Searching / filtering datagridview in c#

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

问题描述

大家好...
我希望能够在我的datagridview中使用过滤器,但是我不知道该怎么做...
谁能帮助我...

Hello everyone...
I want to be able to use a filter in my datagridview but i dont know how to do it...
Can anyone pls help me out...

推荐答案

尝试这些博客
http://social.microsoft.com/Forums/zh-美国/interopstandards/thread/0ca444a3-a091-4951-9a69-899f4f165a70 [ http://stackoverflow. com/questions/1224291/how-to-filter-c-sharp-winform-datagridview-that-was-created-with-visual-studio [
try these blogs
http://social.microsoft.com/Forums/en-US/interopstandards/thread/0ca444a3-a091-4951-9a69-899f4f165a70[^]
http://stackoverflow.com/questions/1224291/how-to-filter-c-sharp-winform-datagridview-that-was-created-with-visual-studio[^]
--NDK


如果columnHeader中的comboBox将解决您的问题,则必须从DataGridViewColumn继承一个类,并从例如DataGridViewTextBoxCell继承一个类,并将datagridview的cellTemplate设置为DataGridViewColumn构造函数中的第二个类.
之后,您必须将所需的控件添加到您的自定义列中.您可以通过usercontrol进行构建,也可以使用comboBox或类似的控件.
所有继承的类都具有绘画方法,您可以重写此方法,并使用单元绑定来获取控件的正确位置.
If a comboBox in columnHeader will solve your problem you must inherit a class from DataGridViewColumn and a class inherit from for example DataGridViewTextBoxCell and set cellTemplate of datagridview to second class in DataGridViewColumn Constructor.
After that you must add your desired control into your custom column.You can build that by usercontrol or if you want you can use a comboBox or something like that.
The all inherited classes have paint method that you can override and use the cellbounds to get proper location for your control.


DataGridView过滤器弹出窗口 [ ^ ]是一个很好的过滤器实现,供您查看.
[具有过滤功能的Datagridview [使用DataViewRowState过滤DataGridView [ http://www.sourcehints.com/articles/how-to-search-for-a-value-in-datagridview.html [
DataGridView Filter Popup[^] is a good filter implementation for you to look at.
This[^] is a good article on implementing a filter as well.
Datagridview with filtering capability[^] is another nice article.
You can user DataViewRowState to filter data. Use DataViewRowState to filter DataGridView[^] explains this approach.

If you are looking for implementing a search, go through http://www.sourcehints.com/articles/how-to-search-for-a-value-in-datagridview.html[^].


这篇关于在C#中搜索/过滤datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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