Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with highlighting rows based on identical values in multiple columns

Hi,

I am using the code below to highlight records where selected column (i.e. yx = column1)have identical values in two or more records. How do I modify it to the the same when I select multiple columns? For example If I select two columns (i.e. yx = column1, column2) from a list box I need to highlight records where values in both columns are identical in two or more records. This is third party Grid Control from ComponentOne.

 Dim cc As Integer = 0
        e.CellStyle.BackColor = DefaultBackColor
        e.CellStyle.ForeColor = DefaultForeColor
        Try
            Dim checkCols As String = yx

            If checkCols.Count > 0 Then

                Dim tempRow = C1Screen1.FocusedSplit.Rows.OfType(Of C1.Win.C1TrueDBGrid.BaseGrid.ViewRow).ToList()
                Dim flag As Boolean = False
                Dim origItem As String = ""
                For Each item As String In checkCols.Split(","c)
                    origItem = origItem + C1Screen1(e.Row, item.Trim("'"c)).ToString()
                Next
                For j As Integer = 0 To tempRow.Count - 1
                    Dim tempItem As String = ""
                    For Each item As String In checkCols.Split(","c)
                        tempItem = tempItem + C1Screen1(j, item.Trim("'"c)).ToString()
                    Next
                    If Not flag AndAlso e.Row <> j Then
                        If origItem = tempItem Then
                            flag = True
                        End If
                    End If
                Next
                e.CellStyle.BackColor = DefaultBackColor
                e.CellStyle.ForeColor = DefaultForeColor
                If flag Then
                    e.CellStyle.BackColor = Color.DarkGreen
                    e.CellStyle.ForeColor = Color.White
                    cc = 1
                    Exit Sub
                Else
                    e.CellStyle.BackColor = DefaultBackColor
                    e.CellStyle.ForeColor = DefaultForeColor
                    cc = 0
                End If
            End If
            '   C1Screen1.Refresh()
            If cc <> 1 Then
                C1Screen1.Refresh()
                ' MsgBox("No Matches Found")
                'Exit Sub
            End If
        Catch
            ccc = 1
            Exit Sub

        End Try

Thanks,

Victor
ASKER CERTIFIED SOLUTION
Avatar of Victor  Charles
Victor Charles
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial