Results 1 to 6 of 6

Thread: search datagridview

  1. #1
    lional is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    16
    Reputation
    16

    search datagridview

    Hi.

    I have a datagridview that I have allowed the columns to be sorted by clicking on teh column.
    is it possible that after clicking on a calumn to type in for eg. the start of a surname and it then goes to that record

    Thanks

    Lional

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,338
    Reputation
    1543
    How is the grid populated? If the data is coming from a database then you should populate a DataTable and bind it to a BindingSource, then bind that to the grid. You search using the Find method of the BindingSource. That will return the index of the matching item and you assign that to the BindingSource's Position property, which will automatically select that row in the grid.

  3. #3
    lional is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    16
    Reputation
    16
    The grid is populated from a DB. I have multiple columns and what I want is that if you click on a column it then sorts by that column. so whatever is typed on the keyboard will then go to the record in that specific column. I am very new to VB learning it from books but as usual the books are very limited when it comes to the data section. Is there a tutirial that would show me how to use the Find method and do what I want to achieve.

  4. #4
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,338
    Reputation
    1543
    Quote Originally Posted by lional View Post
    Is there a tutirial that would show me how to use the Find method and do what I want to achieve.
    Quite possibly, but I don't keep a link on me. To find one I would have to use a search engine, which you can do just as easily. As is always the case, you should start by reading the MSDN documentation. If that doesn't give you enough information, then search for examples, etc.

  5. #5
    lional is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    16
    Reputation
    16
    I am battling with this a bit. Is there not any sample code that I can look at to try and get an understanding.

  6. #6
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,338
    Reputation
    1543
    Quote Originally Posted by lional View Post
    I am battling with this a bit. Is there not any sample code that I can look at to try and get an understanding.
    I'm sure there is but it's not going to find you. You have to find it. You don't need any programming experience to search the web.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking