Visual Basic-Datagridview的&文字框过滤 [英] Visual Basic - Datagridview's & Text Box filtering

查看:84
本文介绍了Visual Basic-Datagridview的&文字框过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在使用的数据库即时通讯程序我无法更改名称,因此即时通讯使用的名称在WHERE语句中无法很好地工作,而且我相信我也无法在WHERE语句中使用别名.

(请参阅附件以获取当前表单的屏幕截图) http://s18.postimage.org/7s4it1srd/form_screenshot_with_code_behind.png [^ ]

我的目标是:-
用户可以在表单的左上角输入两个大小,

跨越= 90
大约= 50

那么这两个尺寸将有一个范围,即大于或小于5(位于它们下方的下两个框称为范围)

单击搜索按钮后,右侧的4个框将填充每个尺寸的上限和下限,具体取决于范围
90-5 = 85(check1.text)
90+ 5 = 95(check2.text)
50-5 = 45(check3.text)
50 +5 = 55(check4.text)

到目前为止,我必须到达&一切都很好.

我要对这4个数字执行的操作是在底部过滤我的datagridview以反映用户输入.

当我单击搜索按钮时,我想看到的是
(非常糟糕的非编码在这里-但我想通过针对Across& Round的范围来过滤我的datagridview结果)
可能添加到搜索按钮中的代码,

datagridview1 update([MM-Across] .value是> check1.text但< check2.text并且[MM-Round] .value是> Check3.text但< check4.text),>

我是VB& amp;的新手.我必须承认SQL,但是我试图自我学习,但是我确实停留在此部分.


在此先感谢您提供的任何支持或帮助,这里的一些项目是我在网上看了5个小时后最接近我想大致执行的工作了.

NaZReD

UK

at the moment the database im working with i cannot change the names, so im stuck with names that will not work very well in the WHERE statements and i belive i cannot use alias in WHERE statements either.

(see attached for screen shot of current form)http://s18.postimage.org/7s4it1srd/form_screenshot_with_code_behind.png[^]

my goal is:-
a user can input two sizes on the top left hand side of my form,

Across =90
Around =50

these two sizes will then have a range to them i.e. more or less than 5 (next two boxes below them called range)

once i click the search button the 4 boxes on the right will be populated with the upper and lower limits for each size dependent on the range
90 - 5 = 85 (check1.text)
90+ 5 = 95(check2.text)
50 - 5 = 45(check3.text)
50 +5 = 55 (check4.text)

This is so far where i have got to & all is working good.

what i want to do with these 4 numbers is filter my datagridview at the bottom to reflect the users inputs.

what i would like to see happen when i click the search button is
(very bad non coding here - but i want is to filter my datagridview result via a range against Across & Round)
Add to the search button coding maybe,

datagridview1 update( [MM-Across].value is > check1.text but < check2.text AND ALSO [MM-Round].value is > Check3.text but <check4.text),>

im a complete novice to VB & SQL i must admit but im trying to self learn, but im really stuck on this section.


Thank you in advance for any support or help you could offer me,a few projects on here was the closest i can find on the net to what i want to roughly do after 5 hours of looking today)

NaZReD

UK

推荐答案

看看Bindingsource Filter属性,它将在绑定的DGV中过滤当前数据集,而无需调用数据库,因此您可以选择一个最初的一堆记录基于外部边界,然后在条件内进行本地过滤.

Filter属性有效地在本地添加了SQL WHERE子句.

接下来要考虑的是SQL BETWEEN语句.您可以使用单个BETWEEN,而不必使用一对外部检查.

因此,您可能会遇到类似的情况;在5和10之间选择*.


在处理大量事件/警报记录时,我使用了这种方法.最初,我根据两个日期之间的记录调用了外部视图,并在其中填充了一个外部范围,然后将其拉回客户端.然后,用户根据其他标准进行过滤,例如标签名称,使用FILTER属性的警报组.

另外,如果您使用的是大型数据集,请确保以异步方式拉回数据,以便在数据库中搜索数据时UI不会停止.

希望这些能对您的研究有所帮助:)
Have a look at the Bindingsource Filter property, this will filter the current dataset within the bound DGV without a call back to the database, so you could select an initial bunch of records based on an outerboundary and then filter locally within a criteria.

The Filter property effectively adds an SQL WHERE clause locally.

The next thing to consider is the SQL BETWEEN statement. Rather than having an pair of outer checks, you can use a single BETWEEN.

So, you could have something like; Select * where something BETWEEN 5 AND 10.


I used this approach when working with a bunch of event/alarm records. I initially called and populated the view with a outer range based on records between 2 dates and pulled these back to the client. The user then filter based on other criteria, e.g. tag names, alarm groups using the FILTER property.

Also, if you are working with a large dataset, make sure you pull back the data asynchronously, so the UI doesn''t stall while data is being searched for in the database.

Hope these are a few things to help your research a bit more :)


这篇关于Visual Basic-Datagridview的&amp;文字框过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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