Solved

add search textbox to a VB datagrid then highlight the cell

Posted on 2007-12-06
5
1,785 Views
Last Modified: 2013-11-27
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
Comment
Question by:harveygs
  • 2
  • 2
5 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20421341
is this a Windows app/ web app?
0
 
LVL 1

Author Comment

by:harveygs
ID: 20421578
windows application
0
 
LVL 21

Accepted Solution

by:
surajguptha earned 500 total points
ID: 20422450
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
 
LVL 1

Author Comment

by:harveygs
ID: 20431594
yes that worked fine thanks. I had to put -1 at the end because it went out of range.
0
 

Expert Comment

by:Carlo45
ID: 26194780
harveygs, can you post your code please..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now