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
Re: filter all values in datagridview which are greater than given value into textbox
Quote:
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?
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
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.
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.
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
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)"
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