looping through datagrid view anf finding a condition-VBForums
Results 1 to 3 of 3

Thread: looping through datagrid view anf finding a condition

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2015
    Location
    uk
    Posts
    14

    looping through datagrid view anf finding a condition

    Hello
    I am using VB.NET 10.Is it possible to loop through a datagridview,find a certain value in a column and then produce the next row down.
    For example lets say I was looping through the following datagrid.

    Name Hobby FavColour job
    fred eating blue plumber
    berty movies red teacher
    nancy gardening white gardener
    horace kite flying yellow plasterer

    When I reach a certain value in a cell(column) lets say movies(bert's hobby) I would like to then be able to display the NEXT row down,here it would be the Nancy Row.Any help much appreciated.
    Custard

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,602

    Re: looping through datagrid view anf finding a condition

    Yes, of course it's possible. Just use a For loop. Loop through the Rows of the grid in your For loop and, when you find a row of interest, you simply get the row at the next index, display it and then exit the loop.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2015
    Location
    uk
    Posts
    14

    Re: looping through datagrid view anf finding a condition

    Hi jmcilhinney.Thanks for your reply.So how is it done then,because I dont know.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.