Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB.NET Filtering out datagrid data with combo box

VB.NET Filtering out datagrid data with combo box

Scheduled Pinned Locked Moved Visual Basic
csharpdatabaseregexquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shrimpersfan
    wrote on last edited by
    #1

    Hi there. I currently have an application where a user can select items from a combo box and then display the results in a datagrid view depending on what is selected in the combo box. This is fine because the user is selcting an exact match from what is in the sql connection but i need the user to be able to select a range from a different combo box, ie - if a field/row in the datagrid is 'Total' then i would want the user to be able to filter out all totals between '100 and 200' or '201 - 300' etc. I have tried using a case statement but am unsure if this is the right way of going about it.

    J Z 2 Replies Last reply
    0
    • S Shrimpersfan

      Hi there. I currently have an application where a user can select items from a combo box and then display the results in a datagrid view depending on what is selected in the combo box. This is fine because the user is selcting an exact match from what is in the sql connection but i need the user to be able to select a range from a different combo box, ie - if a field/row in the datagrid is 'Total' then i would want the user to be able to filter out all totals between '100 and 200' or '201 - 300' etc. I have tried using a case statement but am unsure if this is the right way of going about it.

      J Offline
      J Offline
      Jon_Boy
      wrote on last edited by
      #2

      Not sure how you have your data setup in the app. If you have a data table, use a dataview to filter the data as needed. The dataview.RowFilter is the where clause in a select statement. So, just like you would do in SQL, your filter would be something like "Totals >= 100 and Totals <= 200" or "Totals BETWEEN 100 and 200" I took the example below from the MSDN help which is very descriptive on the dataview.

      Private Sub MakeDataView()
      Dim view As DataView = New DataView
      With view
      .Table = DataSet1.Tables("Suppliers")
      .AllowDelete = True
      .AllowEdit = True
      .AllowNew = True
      .RowFilter = "City = 'Berlin'"
      .RowStateFilter = DataViewRowState.ModifiedCurrent
      .Sort = "CompanyName DESC"
      End With

      ' Simple-bind to a TextBox control
      Text1.DataBindings.Add("Text", view, "CompanyName")
      

      End Sub

      Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

      1 Reply Last reply
      0
      • S Shrimpersfan

        Hi there. I currently have an application where a user can select items from a combo box and then display the results in a datagrid view depending on what is selected in the combo box. This is fine because the user is selcting an exact match from what is in the sql connection but i need the user to be able to select a range from a different combo box, ie - if a field/row in the datagrid is 'Total' then i would want the user to be able to filter out all totals between '100 and 200' or '201 - 300' etc. I have tried using a case statement but am unsure if this is the right way of going about it.

        Z Offline
        Z Offline
        zhuwy16
        wrote on last edited by
        #3

        :) ok

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups