根据列表框选择的项目过滤DataGridView [英] Filtering DataGridView based on listbox selected items

查看:75
本文介绍了根据列表框选择的项目过滤DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



所以我想根据从listBox1中挑选的所选项目(超过1个)过滤我的datagridview。



所以让我说我得到这样的查询:



SELECT * from Table其中的值为('+我需要的东西+ ')



listbox1有以下物品:



Text1

Text2

Text3

Text4



listbox1是多选

Hello,

So I'd like to filter my datagridview based on selected items (more than 1) picked from listBox1.

So let's say I got query like this:

"SELECT * from Table where Value in('"+something I need+"')

listbox1 has items like:

Text1
Text2
Text3
Text4

listbox1 is multi-select

推荐答案

您好


1.让列表框具有分配给后台项目的value属性



2.现在每当用户选择一个列表框项目时,都会使用逗号分隔格式动态构建一个字符串例如:(1,2)



3.现在将这些值传递给如果尚未填充gridview,则为DB的参数。断开逗号分隔值并将它们放在临时表中,并将gridview结果与此表连接,然后传递e值返回到前端gridview,以便它只显示这些记录。



希望这会有所帮助。如果您需要任何其他信息,请告诉我。

如果是,请标记为答案。
Hi
1. Let the listbox have the value property assigned to the items in the background

2. Now whenever the user selects a listbox item have a string dynamically built using the comma separated format Eg: (1,2)

3. Now pass these values as parameters to the DB in case the gridview is not yet populated. Break the comma separated values and place them in a temp table and join the gridview results with this table and then pass these values back to the front end gridview so that it shows only these records.

Hope this helps. Let me know if you need any other information.
Please mark as answer if it is.


这篇关于根据列表框选择的项目过滤DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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