Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Datagrid - Select row based on row value

Posted on 2004-10-27
6
Medium Priority
?
1,535 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:flavo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Accepted Solution

by:
jameskearney earned 800 total points
ID: 12419891
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
 
LVL 28

Assisted Solution

by:iboutchkine
iboutchkine earned 400 total points
ID: 12420937
and  here is how to select row

DataGrid1.Select(DataGrid1.CurrentRowIndex)
0
 
LVL 8

Assisted Solution

by:wguerram
wguerram earned 800 total points
ID: 12422224
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Author Comment

by:flavo
ID: 12427186
Thanks guys.
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12428174
You're welcome.
0
 
LVL 1

Expert Comment

by:jameskearney
ID: 12431434
no probs
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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 …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 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