[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1798
  • Last Modified:

add search textbox to a VB datagrid then highlight the cell

I want to have a text box with say a 'go' submit button that will search through my displayed datagrid (visual basic)  and display "not found" or if found the cell found is highlighted.
I am a begginer to VB
I am using PCstatusDataset, Workstaionbindingsource and workstationstableadaptor
i have imports system.data.sqlclient
the data grid is called workstationsdatagridview
the database is called pcstatus. The table is called workstations the two columns I wish to search through are called 'PC'  and 'Username'. and then the cursor moves to that cell that is found.

Thanks
steve

0
harveygs
Asked:
harveygs
  • 2
  • 2
1 Solution
 
surajgupthaCommented:
is this a Windows app/ web app?
0
 
harveygsAuthor Commented:
windows application
0
 
surajgupthaCommented:
Here's the pseudo code

        For index As Integer = 1 To DataGridView1.Rows.Count
            For index1 As Integer = 1 To DataGridView1.Rows(index).Cells.Count
                If (DataGridView1.Rows(index).Cells(index1).Value.ToString().Contains(searchString)) Then
                    DataGridView1.Rows(index).Cells(index1).Selected = True
                End If
            Next
        Next
0
 
harveygsAuthor Commented:
yes that worked fine thanks. I had to put -1 at the end because it went out of range.
0
 
Carlo45Commented:
harveygs, can you post your code please..
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now