Help with converting code for C1TrueDBGrid for a FlexGrid in my ASP.NET MVC App

Posted by: Victor.m.charles.civ on 7 September 2019, 10:27 am EST

  • Posted 7 September 2019, 10:27 am EST

    Hello,

    I’m using the code below to highlight rows (Green and white) in C1AOP5 and C1AOP40T where both Grids have identical data in their NSN columns. How do I modify the code to achieve the same in two FlexGrids?

    Private Sub C1AOP5_FetchCellStyle(sender As Object, e As C1.Win.C1TrueDBGrid.FetchCellStyleEventArgs) Handles C1AOP5.FetchCellStyle

    'Highlight columns with textbox value

    If apply = True Then

    If C1AOP5(e.Row, e.Col) = FormGlobalMain.TextBox1.Text Then

    e.CellStyle.BackColor = C1AOP5.HighLightRowStyle.BackColor

    e.CellStyle.ForeColor = Color.White

    End If

    End If

    If RadioButton4.Checked And ComboBox2.SelectedIndex = 0 Then

    If e.Col <> 0 Then

    If e.Row <> 0 Then

    For i As Integer = 0 To e.Row - 1

    If C1AOP5(e.Row, 0) = C1AOP5(i, 0) Then

    If C1AOP5(e.Row, e.Col) = C1AOP5(i, e.Col) Then

    e.CellStyle.BackColor = Color.Green

    e.CellStyle.ForeColor = Color.White

    End If

    End If

    Next

    End If

    If e.Row <> C1AOP5.Splits(0).Rows.Count - 1 Then

    For i As Integer = e.Row + 1 To C1AOP5.Splits(0).Rows.Count - 1

    If C1AOP5(e.Row, 0) = C1AOP5(i, 0) Then

    If C1AOP5(e.Row, e.Col) = C1AOP5(i, e.Col) Then

    e.CellStyle.BackColor = Color.Green

    e.CellStyle.ForeColor = Color.White

    End If

    End If

    Next

    End If

    End If

    End If

    End Sub

    Private Sub C1AOP5_FetchRowStyle(sender As Object, e As C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs) Handles C1AOP5.FetchRowStyle

        Try
            Dim checkCols As String = yx
            If checkCols.Count > 0 Then
                Dim tempRow = C1AOP5.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 + C1AOP5(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 + C1AOP5(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
            Else
    
            End If
        Catch
            ccc = 1
            Exit Sub
        End Try
    End Sub
    

    Private Sub C1AOP5_SelChange(sender As Object, e As CancelEventArgs) Handles C1AOP5.SelChange

    s.Clear()

    For Each row In Me.C1AOP5.SelectedRows

    s.Add(C1AOP5.Columns(“NSN”).CellText(row))

    Next

    C1AOP40T.Refresh()

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

    If s.Contains(C1AOP40T.Columns(“NSN”).CellText(i)) Then

    C1AOP40T.SelectedRows.Add(i)

    End If

    If s.Count = 0 Then

    C1AOP40T.SelectedRows.Clear()

    End If

    Next

    e.Cancel = True

    End Sub

    Private Sub C1AOP40T_FetchRowStyle(sender As Object, e As FetchRowStyleEventArgs) Handles C1AOP40T.FetchRowStyle

    Try

    Dim checkCols As String = yx

            If checkCols.Count > 0 Then
    
                Dim tempRow = C1AOP40T.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 + C1AOP40T(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 + C1AOP40T(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
            Else
            End If
        Catch
            ccc = 1
            Exit Sub
        End Try
    
  • Posted 8 September 2019, 10:20 pm EST

    Hi Victor,

    In MVC FlexGrid, there is formatItem event which can be used to style the cells based on some condition check.

    Please refer to the following demo sample for reference:

    https://demos.componentone.com/ASPNET/LearnMvcClient/C1FlexGrid/CustomCells/1

    Hope it helps!

    Regards,

    Manish Gupta

Need extra support?

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

Learn More

Forum Channels