Datagrid - Select row based on row value

Hey!

Say i have a datagird with data like

Dave :  $10.00
Bill   :   $20.00
Steve :  $50.00

How do i select the row with Dave??

Cheers!

Dave
LVL 34
flavoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jameskearneyCommented:
something like:

            Dim wibble As New DataGrid
            Dim table As DataTable = CType(wibble.DataMember, DataTable)
            For Each row As DataRow In table.Rows
                If CType(row.Item("Name"), String).Trim.Equals("Dave") Then
                    'do something - select the row here....
                End If
            Next

hth,

james
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
iboutchkineCommented:
and  here is how to select row

DataGrid1.Select(DataGrid1.CurrentRowIndex)
0
wguerramCommented:
Try this:

 ' Get the Currency Manager by using the BindingContext of the DataGrid
        Dim cm As CurrencyManager = CType(Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember), CurrencyManager)

        ' Retrieve the default DataView of the DataGrid
        Dim dv As DataView = CType(cm.List, DataView)

        Dim drv() As DataRowView
        'Sort the DataView coumn to search
        dv.Sort = "CustomerID"
        'Search the row
        drv = dv.FindRows(TextBox1.Text)

        'If found position the cursor in the row found
        If drv.Length > 0 Then
            cm.Position = cm.List.IndexOf(drv(0))
        End If
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

flavoAuthor Commented:
Thanks guys.
0
wguerramCommented:
You're welcome.
0
jameskearneyCommented:
no probs
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.