Results 1 to 8 of 8

Thread: filter all values in datagridview which are greater than given value into textbox

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    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

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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!

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    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

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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!

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    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.

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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!

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    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)"

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    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
  •  



Click Here to Expand Forum to Full Width