Help with deleting Rows in C1TrueDBGrid based on value in cell

Posted by: Victor.m.charles.civ on 28 January 2020, 7:54 am EST

    • Post Options:
    • Link

    Posted 28 January 2020, 7:54 am EST

    Hello,

    How do I modify the code below to delete/hide rows in my Grid if the data in the Remarks column does not include the word “Qualified”?

    For j As Integer = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1

            If C1TrueDBGrid3.Splits(0).DisplayColumns("REMARKS").ToString <> "(Qualified") Then​
    
                C1TrueDBGrid3.Splits(0).Rows(j).Visible = False​
    
            End If​
    



    Next

  • Posted 28 January 2020, 8:14 pm EST

    Hi Victor,

    Your case has been replied on the given link :

    http://supportone.componentone.com/casedetail/418662

    Please continue the thread there only.

    Regards,

    Prabhat

  • Posted 29 January 2020, 1:18 am EST

    Hello,

    Thank you, it works but not when I have two separate words.

    For example the following works, but if I use “IS QUALIFIED” it does not work.

    For j As Integer = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1

    If C1TrueDBGrid3.Splits(0).DisplayColumns(“REMARKS”).DataColumn.CellValue(j).ToString.Contains(“QUALIFIED”) = False Then

    C1TrueDBGrid3.Splits(0).Rows(j).Visible = False

    End If

    Thanks,

    Victor

  • Posted 29 January 2020, 2:20 am EST

    Hello again,

    I works with two separate words, my issue now is it does not work when I change the size of the columns after applying the code. How do I still change the width of the columns and caption when applying the code? Below is the code that does not work after I am trying the modify the Grid’s columns and captions.

        For j As Integer = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1
            If C1TrueDBGrid3.Splits(0).DisplayColumns("REMARKS").DataColumn.CellValue(j).ToString.Contains("IS QUALIFIED") = False Then
                C1TrueDBGrid3.Splits(0).Rows(j).Visible = False
            End If
        Next
    '******Code above does not with code below************
        C1TrueDBGrid3.Splits(0).DisplayColumns("COUNTRY").Visible = False
        C1TrueDBGrid3.Splits(0).DisplayColumns("SCOUNTRY").Visible = False
        Me.C1TrueDBGrid3.Columns("AGD4").Caption = "NMN"
        Me.C1TrueDBGrid3.Columns("AGD1").Caption = "Advert DESCRIPTION"
        Me.C1TrueDBGrid3.Columns("AGD").Caption = "NARC DESCRIPTION"
        Me.C1TrueDBGrid3.Columns("SN").Caption = "SN"
        C1TrueDBGrid3.Splits(0).DisplayColumns("NSN").Width = 165
        C1TrueDBGrid3.Splits(0).DisplayColumns("NAS").Width = 160
    

    End Sub

    Thanks,

    Victor

  • Posted 29 January 2020, 2:36 am EST

    Hello again,

    I noticed changing the caption creates the problem, not changing the width of the field. Also noticed it does not work when applying a second condition in the code, as shown below. How do I include a second condition the length has to be greater the 16 otherwise hide the row?

    For j As Integer = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1

    If C1TrueDBGrid3.Splits(0).DisplayColumns(“REMARKS”).DataColumn.CellValue(j).ToString.Contains(“NATO QUALIFIED”) = False And Len(“NSN”) > 16 = False Then

    C1TrueDBGrid3.Splits(0).Rows(j).Visible = False

    End If

    Next

  • Posted 29 January 2020, 2:53 am EST

    Hello,

    Made change below but still does not work when setting two conditions.

    For j As Integer = 0 To C1TrueDBGrid3.Splits(0).Rows.Count - 1

    ’ If C1TrueDBGrid3.Splits(0).DisplayColumns(“REMARKS”).DataColumn.CellValue(j).ToString.Contains(“NATO QUALIFIED”) = False And Len(“NSN”) > 16 = True Then

    If C1TrueDBGrid3.Splits(0).DisplayColumns(“REMARKS”).DataColumn.CellValue(j).ToString.Contains(“IS QUALIFIED”) = False And C1TrueDBGrid3.Splits(0).DisplayColumns(“NSN”).ToString.Length > 16 = False Then

    C1TrueDBGrid3.Splits(0).Rows(j).Visible = False

    End If

    Next

    Thanks,

    Victor

  • Posted 29 January 2020, 3:31 am EST

    Hello again,

    It works with Part A for one condition, but does not work with Part B for two conditions. How do I get to work for part B?

    Part A.

    If C1TrueDBGrid3.Splits(0).DisplayColumns(“NSN”).DataColumn.CellText(j).Length > 16 = False Then

    C1TrueDBGrid3.Splits(0).Rows(j).Visible = False

    End If

    Part B.

    ’ If C1TrueDBGrid3.Splits(0).DisplayColumns(“REMARKS”).DataColumn.CellValue(j).ToString.Contains(“IS QUALIFIED”) = False And C1TrueDBGrid3.Splits(0).DisplayColumns(“NSN”).DataColumn.CellText(j).Length > 16 = False Then

    C1TrueDBGrid3.Splits(0).Rows(j).Visible = False

    End If

    Thanks,

    Victor

  • Posted 29 January 2020, 10:06 pm EST

    Hi Victor,

    >>but if I use “IS QUALIFIED” it does not work.

    Sorry it is working fine at our end. In our attached sample I have hide the rows that have “Sales Representative” value in the “Title” column.

    >>How do I still change the width of the columns and caption when applying the code?

    The code provided by you is working fine at our end. Please see the attached sample.

    >>How do I include a second condition the length has to be greater the 16 otherwise hide the row?

    Please find the below given code in our attached sample where both the conditions are working fine.

    For j As Integer = 0 To C1TrueDBGrid1.Splits(0).Rows.Count - 1
      If C1TrueDBGrid1.Splits(0).DisplayColumns("Title").DataColumn.CellValue(j).ToString.Contains("Sales Representative") And C1TrueDBGrid1.Splits(0).DisplayColumns("Title").DataColumn.CellValue(j).ToString.Length > 12 Then
       C1TrueDBGrid1.Splits(0).Rows(j).Visible = False
      End If
    Next
    
    

    All the above desired scenarios are working fine at our end, please modify the attached sample accordingly or provide your stripped down sample replicating the issue so that we can replicate the same issue at our end and provide you a helpful solution.

    Regards,

    Prabhat Sharma

    TDBHideRowDemo.zip

Need extra support?

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

Learn More

Forum Channels