Solved

Help with selecting rows from grid control

Posted on 2013-01-07
2
230 Views
Last Modified: 2013-01-08
Hello,

I am using the code below to select rows where keySDeactivation = "1,2", which exist in column(0), the code goes through all the steps as indicated in the Msgboxes but for some reason the rows are not selected, any ideas what is wrong with the code?


 Private Sub ViewDataC(ByVal keyLinkAid As String, ByVal keySDeactivation As String)
        ' MsgBox("TestA" & keySDeactivation) - ok
        If keySDeactivation <> "" Then
            Dim _tableA As DataView = dtMasterA.DefaultView
            '   _table.RowFilter = "SDeactivation_ID in (" & keySDeactivation & ")"
            C1SDeactivation.DataSource = _tableA
            MsgBox("COUNTSDEACTIVATION" & C1SDeactivation.RowCount)
            '     keySDeactivation = "1,2,3"
            For i As Integer = 0 To C1SDeactivation.RowCount - 1
                MsgBox("Testb" & keySDeactivation) --ok
                 If C1SDeactivation.Columns(0).CellValue(i).ToString().Contains(keySDeactivation) = True Then

                    C1SDeactivation.SelectedRows.Add(i) ' does not work
                    MsgBox("testc") ---ok
                End If
            Next
        End If
0
Comment
Question by:vcharles
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 38753732
I think you need to go for the syntax link thsi

dataGrid.Rows[index].Selected = true;

chekc this

http://stackoverflow.com/questions/6265228/selecting-a-row-in-datagridview-programatically
0
 

Author Closing Comment

by:vcharles
ID: 38753828
Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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