Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2011, 12:13 PM
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PROBLEM LOOPING AND SEARCHING THROUGH COLUMN

hi all,
i am working on an assignment to search a value in datagridview column if value matched with input textbox then datagrid cursor should move to the cell having that searched vallue and if column has more than one searched values then cursor should move to next cell having that particular searched value and so on .e.g
----------
column1
----------
ANATR
ANTON
AROUT
BERGS
AROUT
BLONP
AROUT
BONAP
---------
suppose that if we search for value AROUT which is in cell nomber 3,5 and 7 when user hit the serch button first time then data grid cursor should move to the 3rd cell and when user again click search button then datagrid cursor should move to the 5th cell and when user click search button third time then datagrid cursor should move to the 7th cell
i have tried many combination with FOR loop and IF condition
but with following code by default FOR loop starts from first row and goes till the 7th row but does not comes back to the first row,and when we click the search button after clicking the 6th row it does not find previous two values which are in 3rd and 5th row'
how can i loop back to the first row.
it is hard to explain for me but i hope that i am able to convey my point
my code is
Code:
 Dim j As Integer
        Dim i As Integer
        j = DataGridView1.Rows.Count - 2
        i = DataGridView1.CurrentRow.Index + 1
        For i = i To j
            If DataGridView1.Rows(i).Cells(3).Value.ToString.ToLower = TextBox4.Text.ToLower Then
                DataGridView1.CurrentCell = DataGridView1.Rows(i).Cells(3)
                Exit For
            End If
        Next





Similar Threads
Thread Thread Starter Forum Replies Last Post
xml looping problem harpua Classic ASP XML 0 November 18th, 2005 06:36 PM
searching option problem, please help mateenmohd Classic ASP Databases 12 June 17th, 2003 06:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.