Help with replacing Combox control with C1Multiselect control to filter Grid

Posted by: Victor.m.charles.civ on 5 April 2020, 6:47 am EST

    • Post Options:
    • Link

    Posted 5 April 2020, 6:47 am EST

    Hello,

    I’m using the code below to filter two Grids based on one field selected from a Combobox, How do I modify it to work when selecting one or more fields from a C1MultiSelect control?

    Dim str As New StringBuilder

    str.Append(“”)

    For i As Integer = 0 To C1Screen1.Splits(0).Rows.Count - 1

    For j As Integer = i + 1 To C1Screen1.Splits(0).Rows.Count - 1

    If C1Screen2(i, CBox1.Text) <> “” And C1Screen2(i, CBox1.Text) <> “N/A” Then

    If C1Screen1(i, CBox1.Text) = C1Screen1(j, CBox1.Text) Then

    If Not str.ToString.Contains(C1Screen1(i, CBox1.Text).ToString) Then

    str.Append(C1Screen1(i, CBox1.Text) + “,”)

    End If

    Exit For

    End If

    End If

    Next

    Next

    C1Screen1.Columns(“NSN”).FilterMultiSelect = True

    C1Screen1.Columns(“NSN”).FilterSeparator = “,”

    C1Screen1.Columns(“NSN”).FilterText = str.ToString().Remove(str.Length - 1, 1)

    Thanks,

    Victor

  • Posted 5 April 2020, 7:00 am EST

    Hello,

    Another option is to use another Grid control to select the fields instead of a C1MultiSelect control. Below is the code I’m using to highlight records with 2 or more identical records, instead of filtering when selecting multiple rows from a Grid control.

    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

    Exit Sub

    End Try

    End Sub

  • Posted 5 April 2020, 9:22 pm EST

    Hi Victor,

    Please share your stripped-down sample that has the ComboBox. So that we can modify it accordingly to meet your requirements.

    And share an example with the input and output that is to be achieved.

    Regards,

    Prabhat Sharma.

  • Posted 5 April 2020, 11:33 pm EST

    Hello,

    Enclosed is an example using the Combobox control.

    Thanks,

    VictorWindowsApp1.zip

  • Posted 6 April 2020, 9:19 pm EST

    Hi Victor,

    The sample you attached has only one TrueDBGrid and in your initial post, you have mentioned that you want to compare two grids so please modify the sample accordingly to show the complete data that is to be compared using MultiSelect control. It will help us to assist you accordingly.

    Regards,

    Prabhat Sharma.

  • Posted 8 April 2020, 12:32 am EST

    Hello Prabhat,

    Enclosed is the sample project with two grids when I’m filtering Grid1 by NSN and Grid2 by AGD4.

    Thanks,

    Victor WindowsApp1.zip

  • Posted 8 April 2020, 10:15 pm EST

    Hi Victor,

    You can use the code snippet given below to use the C1MultiSelect control in place of ComboBox in your sample:

      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            For item = 0 To C1MultiSelect1.SelectedItems.Count - 1
                Dim x As String
                x = C1MultiSelect1.SelectedValues(item)
                Dim str As New StringBuilder
                str.Append("")
                For i As Integer = 0 To C1Screen1.Splits(0).Rows.Count - 1
                    For j As Integer = i + 1 To C1Screen1.Splits(0).Rows.Count - 1
                        If C1Screen2(i, x) <> "" And C1Screen2(i, x) <> "N/A" Then
                            If C1Screen1(i, x) = C1Screen1(j, x) Then
                                If Not str.ToString.Contains(C1Screen1(i, x).ToString) Then
                                    str.Append(C1Screen1(i, x) + ",")
                                End If
                                Exit For
                            End If
                        End If
                    Next
                Next
                C1Screen1.Columns(x).FilterMultiSelect = True
                C1Screen1.Columns(x).FilterSeparator = ","
                C1Screen1.Columns(x).FilterText = str.ToString().Remove(str.Length - 1, 1)
            Next
        End Sub
    

    Note: Just add a MultiSelect control on your form and populate it with the column name that you want to include for formatting.

    Regards,

    Prabhat Sharma.

  • Posted 9 April 2020, 12:12 am EST

    Hello Prabhat,

    Thank you for the solution, how do you also filter using the “AND” option?

    For example two or more records need to have identical data in all selected fields to be displayed.

    Thanks,

    Victor

  • Posted 10 April 2020, 12:47 pm EST

    Hello Prabhat,

    How do I avoid “Not allowed due to bound Grid” error message, When trying to display records found in a textbox? TextBox1.Text = C1Screen1.Rows.Count

    If RFilter.Checked = True Then

    For item = 0 To C1MultiSelect1.SelectedItems.Count - 1

    Dim x As String

    x = C1MultiSelect1.SelectedValues(item)

    Dim str As New StringBuilder

    str.Append(“”)

    For i As Integer = 0 To C1Screen1.Splits(0).Rows.Count - 1

    For j As Integer = i + 1 To C1Screen1.Splits(0).Rows.Count - 1

    ’ If C1Screen2(i, x) <> “” And C1Screen2(i, x) <> “N/A” Then

    If C1Screen1(i, x) = C1Screen1(j, x) Then

    If Not str.ToString.Contains(C1Screen1(i, x).ToString) Then

    str.Append(C1Screen1(i, x) + “,”)

    End If

    Exit For

    End If

    ’ End If

    Next

    Next

    C1Screen1.Columns(x).FilterMultiSelect = True

    C1Screen1.Columns(x).FilterSeparator = “,”

    C1Screen1.Columns(x).FilterText = str.ToString().Remove(str.Length - 1, 1)

    Next

    TextBox1.Text = C1Screen1.Rows.Count *Error

    End If

  • Posted 10 April 2020, 1:25 pm EST

    Hello Prabhat,

    I was able to solve issue in previous message using Rowcount instead of Rows.count, but noticed another issue with filtering the Grid. When I run a search for 104 with BEL and USA, I receive 5 records than filter COUNTRY column for two or more records with same country, the code is applied to all the records originally on the Grid before I ran my search, you’ll notice the filter is also applied to chapter 105. How do I fix this issue and only filter the records that are visible on the Grid?

    Thanks,

    VictorWindowsApp1A.zip

  • Posted 13 April 2020, 12:16 am EST

    Hi Victor,

    Thank you for the sample.

    Sorry, but we didn’t get the real issue that you are facing in your sample so you are requested to please share a use-case/example that will help us to understand the real issue that you are facing.

    Regards,

    Prabhat Sharma.

  • Posted 13 April 2020, 1:50 am EST

    Hello Prabhat,

    Apparently when I try to filter records from the Grid using the MultiSelect control, it’s filtering data not displayed on the Grid.

    For example,

    a) If select 104,105 with BEL and USA the Grid displays 4 records, than

    b) When I select NSN from the MultiSelect control to filter the GRID for all records wit same NSN, I receive 3 records. The record for SN 10412 should not have been displayed because it was not included in the Grid when I ran the filter.

    Thanks,

    VictorWindowsApp1A.zip

  • Posted 13 April 2020, 7:57 pm EST

    Hi Victor,

    I have modified the sample as per your comments, please have a look and let us know if you have any doubts regarding this.

    Regards,

    Prabhat Sharma.

    WindowsApp1A_Modified.zip

  • Posted 13 April 2020, 10:28 pm EST

    Hello Prabhat,

    Thank you for the solution, how do you highlight the Grid for each column selected in the MultiSelect control?

    Thanks,

    Victor

  • Posted 14 April 2020, 2:43 am EST

    Hello Prabhat,

    I just noticed an issue when sorting the columns in the Grid. It sorts all the data in the table as opposed to only the data displayed on the Grid. How do I fix this issue?

    Thanks,

    Victor

  • Posted 14 April 2020, 11:23 am EST

    Hello Prabhat,

    I’m noticing the following error when using your code in my project.:

    Line: C1Screen1.Columns(x).FilterText = str.ToString().Remove(str.Length - 1, 1)

    Error: System.ArgumentOutOfRangeException: ‘StartIndex cannot be less than zero.

    Parameter name: startIndex’

    Do you know what is causing the error? the code works in the sample project but not my actual project.

    Below is the entire code:

    If RFilter.Checked = True Then

    C1Screen1.Refresh()

    For item = 0 To C1MultiSelect1.SelectedItems.Count - 1

    Dim x As String

    x = C1MultiSelect1.SelectedValues(item)

    ’ MsgBox(x)

    Dim str As New StringBuilder

    str.Append(“”)

    For i As Integer = 0 To C1Screen1.Splits(0).Rows.Count - 1

    For j As Integer = i + 1 To C1Screen1.Splits(0).Rows.Count - 1

    ’ If C1Screen2(i, x) <> “” And C1Screen2(i, x) <> “N/A” Then

    If C1Screen1(i, x) = C1Screen1(j, x) Then

    If Not str.ToString.Contains(C1Screen1(i, x).ToString) Then

    str.Append(C1Screen1(i, x) + “,”)

    End If

    Exit For

    End If

    ’ End If

    Next

    Next

    C1Screen1.Columns(x).FilterMultiSelect = True

    C1Screen1.Columns(x).FilterSeparator = “,”

    C1Screen1.Columns(x).FilterText = str.ToString().Remove(str.Length - 1, 1)

    Dim visible = True

    For row = 0 To C1Screen1.Splits(0).Rows.Count - 1

    visible = False

    For row1 = 0 To C1Screen1.Splits(0).Rows.Count - 1

    If row <> row1 Then

    If C1Screen1.Columns(“SN”).CellValue(row) = C1Screen1.Columns(“SN”).CellValue(row1) AndAlso C1Screen1.Columns(“COUNTRY”).CellValue(row) <> C1Screen1.Columns(“COUNTRY”).CellValue(row1) Then

    visible = True

    Exit For

    End If

    End If

    Next

    C1Screen1.Splits(0).Rows(row).Visible = visible

    Next

            Next
            TextBox1.Text = C1Screen1.RowCount
            Label2.Visible = True
        End If
    
  • Posted 14 April 2020, 7:44 pm EST

    Hi Victor,

    how do you highlight the Grid for each column selected in the MultiSelect control? && It sorts all the data in the table as opposed to only the data displayed on the Grid.

    I have modified the sample as per your comments, please have a look and let us know if you have any doubts regarding this.

    >>I’m noticing the following error when using your code in my project?

    Can you please modify the sample as per your actual sample so that we can assist you accordingly?

    Regards,

    Prabhat Sharma.

    WindowsApp1A_Modified2.zip

  • Posted 14 April 2020, 10:02 pm EST

    Hello Prabhat,

    The filter button is still not working properly in the sample project you sent me.

    When I select 104,105 with BEL, USA for [All Available] option, all the records are displayed as expected. However, when I select NSN from the Multiselect control and press Filter, only 2 records with same NSN are displayed. You’ll notice 3 records should have been displayed for 1305-14-336-9999.

    Thanks,

    Victor

  • Posted 14 April 2020, 10:48 pm EST

    Hello Prabhat,

    Another example:

    When I select 104,105 with BEL, USA for [All Available] option, all the records are displayed as expected. However, when I select FIF from the Multiselect control and press Filter, only record for 10412 should not be displayed since two or more records don’t have N/A under 10412.

    Victor

  • Posted 15 April 2020, 11:02 pm EST

    Hi Victor,

    >>only 2 records with the same NSN are displayed.

    This is because we have updated the sample as per your comment in one of the last posts: “It sorts all the data in the table as opposed to only the data displayed on the Grid.”

    >>You’ll notice 3 records should have been displayed for 1305-14-336-9999.

    Sorry, but I can not see any 3rd record with NSN 1305-14-336-9999, if you are using any other data then please modify the last attached sample accordingly.

    Regards,

    Prabhat Sharma.

  • Posted 16 April 2020, 12:32 am EST

  • Posted 16 April 2020, 12:34 am EST

    Hi Prabhat,

    We should have the same data source, Enclosed is an example of the issue.

    Thanks,

    Victor

  • Posted 16 April 2020, 12:57 am EST

    Hello Prabhat,

    Regarding comment below, you are correct only 2 records should be displayed since they have the information under the same SN.

    When I select 104,105 with BEL, USA for [All Available] option, all the records are displayed as expected. However, when I select FIF from the Multiselect control and press Filter, only record for 10412 should not be displayed since two or more records don’t have N/A under 10412.

  • Posted 16 April 2020, 12:59 am EST

    Replied 16 April 2020, 12:57 am EST

    Hello Prabhat,

    Regarding comment above, I was refereeing to the comment below. Sorry for the confusion.

    You’ll notice 3 records should have been displayed for 1305-14-336-9999.

    Sorry, but I can not see any 3rd record with NSN 1305-14-336-9999, if you are using any other data then please modify the last attached sample accordingly.

  • Posted 16 April 2020, 11:46 pm EST

    Hi Victor,

    Please find the attached sample that we have updated as per your comments and let us know if this helps or not.

    Regards,

    Prabhat Sharma.

    WindowsApp1A_MOdNEw.zip

  • Posted 17 April 2020, 6:35 am EST

    Hello Prabhat,

    Enclosed are two slides showing the steps leading to the error. For example, when I select 104, for BEL and USA, I received to records, when I filter the Grid with only those two records for FIF, 4 records are displayed, apparently it’s still not filtering only records displayed on the Grid. Also enclosed is the sample project.

    Thanks,

    Victor

    Error_List_041720.zipWindowsApp1A.zip

  • Posted 20 April 2020, 12:42 am EST - Updated 3 October 2022, 2:56 pm EST

    Hi Victor,

    Please find the attached sample that we have updated as per your comments as you can see in the attached GIF and let us know if this helps or not.

    Regards,

    Prabhat Sharma.

    WindowsApp1A 3.zip

  • Posted 23 April 2020, 5:47 am EST

    Hello Prabhat,

    Still having issues, please take a look at enclosed files.

    Thanks,

    VictorWindowsApp1A.zipTest_Error_042320.zip

  • Posted 23 April 2020, 9:17 pm EST

    Hi Victor,

    To achieve the desired result you need to replace the button2 click code in your sample with the below-given code snippet:

     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim xyz As String = ""
            For row = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
                xyz = xyz + C1TrueDBGrid3.Columns("SN").CellValue(row) + ","
            Next
    
    
            C1TrueDBGrid3.Refresh()
            For item = 0 To C1MultiSelect1.SelectedItems.Count - 1
                Dim x As String
                x = C1MultiSelect1.SelectedValues(item)
                Dim str As New StringBuilder
                str.Append("")
                For i As Integer = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
                    For j As Integer = i + 1 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
                        ' If C1Screen2(i, x) <> "" And C1Screen2(i, x) <> "N/A" Then
                        If C1TrueDBGrid3(i, x) = C1TrueDBGrid3(j, x) Then
                            If Not str.ToString.Contains(C1TrueDBGrid3(i, x).ToString) Then
                                str.Append(C1TrueDBGrid3(i, x) + ",")
                            End If
                            Exit For
                        End If
                        ' End If
                    Next
                Next
                C1TrueDBGrid3.Columns(x).FilterMultiSelect = True
                C1TrueDBGrid3.Columns(x).FilterSeparator = ","
                C1TrueDBGrid3.Columns(x).FilterText = str.ToString().Remove(str.Length - 1, 1)
                Dim visible = True
    
                '''''''''''''''''''''''''''''''''''''''''''''''''
                If RadioButton2.Checked Then
                    C1TrueDBGrid3.Columns("SN").FilterMultiSelect = True
                    C1TrueDBGrid3.Columns("SN").FilterSeparator = ","
                    C1TrueDBGrid3.Columns("SN").FilterText = xyz.ToString().Remove(xyz.Length - 1, 1)
    
                    For row = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
                        visible = False
                        For row1 = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
                            If row <> row1 Then
                                If C1TrueDBGrid3.Columns("SN").CellValue(row) = C1TrueDBGrid3.Columns("SN").CellValue(row1) AndAlso C1TrueDBGrid3.Columns("COUNTRY").CellValue(row) <> C1TrueDBGrid3.Columns("COUNTRY").CellValue(row1) Then
                                    visible = True
                                    Exit For
                                End If
                            End If
                        Next
                        C1TrueDBGrid3.Splits(0).Rows(row).Visible = visible
                    Next
                Else
    
                    For row = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
                        visible = False
                        For row1 = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
                            If row <> row1 Then
                                If C1TrueDBGrid3.Columns("SN").CellValue(row) = C1TrueDBGrid3.Columns("SN").CellValue(row1) Then
                                    visible = True
                                    Exit For
                                End If
                            End If
                        Next
                        C1TrueDBGrid3.Splits(0).Rows(row).Visible = visible
                    Next
    
                End If
    
            Next
            TextBox1.Text = C1TrueDBGrid3.RowCount
        End Sub
    

    Regards,

    Prabhat Sharma.

  • Posted 24 April 2020, 8:44 am EST

    Hello Prabhat,

    Thank you for the solution, it seems to be working, will run more test with the actual project. How do I modify the code to use a Multiselect Control instead of a DBGrid control to highlight rows with same data in selected field(s). Enclosed is an example in the sample project using a DBGrid.

    Thanks,

    VictorWindowsApp1A.zip

  • Posted 26 April 2020, 9:35 pm EST

    Hi Victor,

    We have modified your last attached sample as per your project where we replaced the DBGrid with the MultiSelect control, please have a look.

    Regards,

    Prabhat Sharma.

    WindowsApp1A_Demo_Mod.zip

  • Posted 28 April 2020, 10:14 am EST

    Hello Prabhat,

    Thank you the solution can you please send me the solution to highlight rows using both options ([All Available] & [Matching Records Only]), similar to Rfilter option.

    Thanks,

    Victor

  • Posted 28 April 2020, 10:59 pm EST

    Hi Victor,

    To implement your given use-case we need to know that how you want to use the Radio buttons, with the MultiSelect control to highlight the rows using CellStyle.

    If you can share some slides of the performed steps and expected output then it will be very helpful for us to provide you a helpful solution.

    Regards,

    Prabhat Sharma.

  • Posted 29 April 2020, 3:20 pm EST

    Hello Prabhat,

    Enclosed is an example of using the “AND” option, I would also like to use the “OR” option.

    Thanks.

    Victor

    Example_Highlight.zip

  • Posted 30 April 2020, 8:57 pm EST

    Hi Victor,

    You can use the code snippet in the FetchRowStyle event as given below to use both AND and OR options for highlighting rows:

      Private Sub C1TrueDBGrid3_FetchRowStyle(sender As Object, e As FetchRowStyleEventArgs) Handles C1TrueDBGrid3.FetchRowStyle
            Try
                Dim checkCols As String = yx
                If RadioButton2.Checked Then
                    If checkCols.Count > 0 Then
                        Dim tempRow = C1TrueDBGrid3.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 + C1TrueDBGrid3(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 + C1TrueDBGrid3(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 = Color.DarkGreen
                            e.CellStyle.ForeColor = Color.White
                        End If
                    End If
                Else
                    If checkCols.Count > 0 Then
                        Dim tempRow = C1TrueDBGrid3.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 + C1TrueDBGrid3(e.Row, item.Trim("'"c)).ToString()
                        Next
                        For j As Integer = 0 To tempRow.Count - 1
                            Dim tempItem As New List(Of String)
                            For Each item As String In checkCols.Split(","c)
                                tempItem.Add(C1TrueDBGrid3(j, item.Trim("'"c)).ToString())
                            Next
                            If Not flag AndAlso e.Row <> j Then
                                For ele As Integer = 0 To tempItem.Count - 1
                                    If origItem.Contains(tempItem(ele)) Then
                                        flag = True
                                    End If
                                Next
                            End If
                        Next
                        If flag Then
                            e.CellStyle.BackColor = Color.DarkGreen
                            e.CellStyle.ForeColor = Color.White
                        End If
                    End If
                End If
    
            Catch
                '  ccc = 1
                Exit Sub
            End Try
        End Sub
    

    Regards,

    Prabhat Sharma.

  • Posted 2 May 2020, 2:52 am EST

    Hello Prabhat,

    Unfortunately it’s still not working, I would like to take the same approach with Filtering the Grid with 2 or more records in the same SN. Enclosed is a screenshot of the issue using the “AND” option.

    Thanks,

    Victor

    SlideA_0502.zip

  • Posted 3 May 2020, 4:33 pm EST

    Hi Victor,

    I have modifed the code snippet of the FetchRowStyle event as per your comments to highlight the rows using AND and OR search options, please have a look:

    Private Sub C1TrueDBGrid3_FetchRowStyle(sender As Object, e As FetchRowStyleEventArgs) Handles C1TrueDBGrid3.FetchRowStyle
           Try
               Dim checkCols As String = yx
               If RadioButton2.Checked Then
                   If checkCols.Count > 0 Then
                       Dim tempRow = C1TrueDBGrid3.FocusedSplit.Rows.OfType(Of C1.Win.C1TrueDBGrid.BaseGrid.ViewRow).ToList()
                       Dim flag As Boolean = False
                       Dim origItem As String = ""
                       Dim origSNItem As String = ""
                       For Each item As String In checkCols.Split(","c)
                           origItem = origItem + C1TrueDBGrid3(e.Row, item.Trim("'"c)).ToString()
                       Next
                       origSNItem = C1TrueDBGrid3(e.Row, "SN")
                       For j As Integer = 0 To tempRow.Count - 1
                           Dim tempItem As String = ""
                           Dim tempSNItem As String = ""
                           tempSNItem = C1TrueDBGrid3(j, "SN")
                           For Each item As String In checkCols.Split(","c)
                               tempItem = tempItem + C1TrueDBGrid3(j, item.Trim("'"c)).ToString()
                           Next
                           If Not flag AndAlso e.Row <> j Then
                               If origItem = tempItem And origSNItem = tempSNItem Then
                                   flag = True
                               End If
                           End If
                       Next
                       If flag Then
                           e.CellStyle.BackColor = Color.DarkGreen
                           e.CellStyle.ForeColor = Color.White
                       End If
                   End If
               Else
                   If checkCols.Count > 0 Then
                       Dim tempRow = C1TrueDBGrid3.FocusedSplit.Rows.OfType(Of C1.Win.C1TrueDBGrid.BaseGrid.ViewRow).ToList()
                       Dim flag As Boolean = False
                       Dim origItem As String = ""
                       Dim origSNItem As String = ""
                       origSNItem = C1TrueDBGrid3(e.Row, "SN")
                       For Each item As String In checkCols.Split(","c)
                           origItem = origItem + C1TrueDBGrid3(e.Row, item.Trim("'"c)).ToString()
                       Next
                       For j As Integer = 0 To tempRow.Count - 1
                           Dim tempItem As New List(Of String)
                           Dim tempSNItem As String = ""
                           tempSNItem = C1TrueDBGrid3(j, "SN")
                           For Each item As String In checkCols.Split(","c)
                               tempItem.Add(C1TrueDBGrid3(j, item.Trim("'"c)).ToString())
                           Next
                           If Not flag AndAlso e.Row <> j Then
                               For ele As Integer = 0 To tempItem.Count - 1
                                   If origItem.Contains(tempItem(ele)) AndAlso origSNItem = tempSNItem Then
                                       flag = True
                                   End If
                               Next
                           End If
                       Next
                       If flag Then
                           e.CellStyle.BackColor = Color.DarkGreen
                           e.CellStyle.ForeColor = Color.White
                       End If
                   End If
               End If
           Catch
               '  ccc = 1
               Exit Sub
           End Try
       End Sub
    

    Regards,

    Prabhat Sharma.

  • Posted 5 May 2020, 11:09 pm EST

    Hello Prabhat,

    It seems to work, but afterwards when I try to sort a column. the Grid becomes blank, how do I avoid this issue?

    Thanks,

    Victor

  • Posted 6 May 2020, 5:18 pm EST

    Hi Victor,

    Sorry, but I can not replicate the issue at our end that when I try to sort a column. the Grid becomes blank.

    Please find the attached sample which is working fine at my end, if you face any issue in using the attached sample then please let us know.

    Regards,

    Prabhat Sharma.

    WindowsApp1A_Demo_Modified.zip

Need extra support?

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

Learn More

Forum Channels