How to use MulttiSelect Control to highlight a Grid control

Posted by: Victor.m.charles.civ on 9 April 2020, 11:40 pm EST

    • Post Options:
    • Link

    Posted 9 April 2020, 11:40 pm EST

    Hello,

    How do I modify the code below to replace a Grid control with a Multiselect control to highlight rows in another Grid. I need to highlight rows using both the “AND”, “OR” approach where selected fields contain two or more records in selected Field(s). The code below only uses the “AND” approach which requires combination of all selected fields have identical data in two or more records. For the “OR” approach, the records are highlighted when either selected fields have identical data in two or more records.

    Button_Click Event:

    yx = “”

    For Each Srow In Me.C1TrueDBGrid9.SelectedRows

    If vc1 > 0 Then

    yx = yx & “, " & “'” & Me.C1TrueDBGrid9.Columns(0).CellText(Srow) & “'”

    Else

    yx = “'” & Me.C1TrueDBGrid9.Columns(0).CellText(Srow) & “'”

    End If

    vc1 = vc1 + 1

    If yx.StartsWith(”,") Then

    yx = yx.Substring(1, yx.Length - 1)

    End If

    Next

    apply = True

    C1Screen1.Refresh()

    C1Screen1.FetchRowStyles = True

    Private Sub C1Screen1_FetchRowStyle(sender As Object, e As C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs) Handles C1Screen1.FetchRowStyle
        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
                If flag Then
                    e.CellStyle.BackColor = Drawing.Color.DarkGreen
                    e.CellStyle.ForeColor = Drawing.Color.White
                End If
            Else
    
            End If
        Catch
            'ccc = 1
        End Try
    End Sub
    

    Thanks,

    Victor

  • Posted 13 April 2020, 7:52 am EST

    Hi Victor,

    The code snippet you provided has numbers of unknowns so we need a stripped-down sample that is using the above-given code snippet with the data. It will help us to assist you in a better way.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels