-
Feb 17th, 2013, 07:03 PM
#1
Thread Starter
Member
filter all values in datagridview which are greater than given value into textbox
Hi there. Can someone help me to resolve this problem because I am tired of searching for solution more than 2 weeks. I need to filter all values in datagridview which are greater than given value into textbox and show them in datagrid.
I found some topics but I can't understand code.
http://www.vbforums.com/showthread.p...ss-than-values
Please understand that I am still learning vb. Thanks
-
Feb 17th, 2013, 07:12 PM
#2
Re: filter all values in datagridview which are greater than given value into textbox
I need to filter all values in datagridview which are greater than given value into textbox and show them in datagrid.
Could you please take a moment to define exactly what you want to do and describe it accurately. The above makes very little sense as it stands unless you really want a separate textbox and a second datagrid(view?) with exactly the same data?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 17th, 2013, 07:14 PM
#3
Thread Starter
Member
Re: filter all values in datagridview which are greater than given value into textbox
Thanks for the reply. I hope that this will help you to understand me.
Example: If given value in textbox is 3:
Column1
1
2
3
4
5
Filtering...
Column1
4
5
-
Feb 17th, 2013, 07:27 PM
#4
Re: filter all values in datagridview which are greater than given value into textbox
Ok. Is this a databound DGV (ie. with a datatable behind) or are the values entered directly either from a file or by the user? If it's the latter then a filter is not advisable as values will be lost and you should go for multiple selection instead. If it's the former it's very easy to set up a dataview and change the datasource to the view rather than the main table.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 17th, 2013, 07:33 PM
#5
Thread Starter
Member
Re: filter all values in datagridview which are greater than given value into textbox
Table is filled by data source. I made an access database and just import it into datagrid. And in form it makes code "Me.Table1TableAdapter.Fill(Me.mydatabaseDataSet.Table1)"
When I start form datagrid get values from database. I need now to filter on them.
-
Feb 17th, 2013, 07:41 PM
#6
Re: filter all values in datagridview which are greater than given value into textbox
Well, the basics are quite simple .... create a dataview and reset the DGV datasource ....
Dim dv As New DataView(Me.mydatabaseDataSet.Table1)
dv.RowFilter = "Column1 > Val(TextBox1.Text)"
DataGridView1.DataSource = dv
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 17th, 2013, 08:04 PM
#7
Thread Starter
Member
Re: filter all values in datagridview which are greater than given value into textbox
It shows a problem at: dv.RowFilter = "Column1 > Val(TextBox1.Text)"
-
Feb 17th, 2013, 08:55 PM
#8
Thread Starter
Member
Re: filter all values in datagridview which are greater than given value into textbox
I resolve this with some modification on second row:
dv.RowFilter = "Column1 > " & TextBox1.Text & ""
@dunfiddlin
Thank you my friend for the help.
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|