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. C#
  4. Filter a Record "Partial key search"

Filter a Record "Partial key search"

Scheduled Pinned Locked Moved C#
databasehelp
3 Posts 2 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.
  • A Offline
    A Offline
    aranhamarvel
    wrote on last edited by
    #1

    :-D Good Morning, i have a problem! i have a form with a TextBox and DataGrid. i fill a DataGrid with DataBase records and when i select a record in DataGrid i show it in textbox! But i want to type a character at textbox and automatically locate the record in DataGrid (Partial key search)! Thanks a lot!

    B 1 Reply Last reply
    0
    • A aranhamarvel

      :-D Good Morning, i have a problem! i have a form with a TextBox and DataGrid. i fill a DataGrid with DataBase records and when i select a record in DataGrid i show it in textbox! But i want to type a character at textbox and automatically locate the record in DataGrid (Partial key search)! Thanks a lot!

      B Offline
      B Offline
      baerten
      wrote on last edited by
      #2

      Hello, you can use a Filter on the Datagrid: At first, you must create a DataView on your table. DataView dv = new DataView(); dv.Table = MyDataSet.Tables["Suppliers"]; Then you can set the RowFilter like this : dv.RowFilter = "City = 'Berlin'"; You can use different FilterOptions, like in SQL : dv.RowFilter = "Name = 'S%'"; S% -> All that begans with S ( Naturally it seems in you case like this : dv.RowFilter = "Name = '" + textbox.Text + "%'"; Then you choose the DataView as DataSource of the Grid There are propably some errors im my example, but the logic is right ( I used it before 1 year and i still don't have the code here ) Good luck

      A 1 Reply Last reply
      0
      • B baerten

        Hello, you can use a Filter on the Datagrid: At first, you must create a DataView on your table. DataView dv = new DataView(); dv.Table = MyDataSet.Tables["Suppliers"]; Then you can set the RowFilter like this : dv.RowFilter = "City = 'Berlin'"; You can use different FilterOptions, like in SQL : dv.RowFilter = "Name = 'S%'"; S% -> All that begans with S ( Naturally it seems in you case like this : dv.RowFilter = "Name = '" + textbox.Text + "%'"; Then you choose the DataView as DataSource of the Grid There are propably some errors im my example, but the logic is right ( I used it before 1 year and i still don't have the code here ) Good luck

        A Offline
        A Offline
        aranhamarvel
        wrote on last edited by
        #3

        thanks dude!! i'll try it "Filter on the DataGrid"!! if i find out anything else i´ll call you again!!! cya!

        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