ComponentOne's FlexGrid Background Color

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 15:20:54

C1 FlexGrid does things a little "WinFormsy" for performance reasons and doesn't utilize DependencyProperties, or styles/templates, so you cannot use data triggers to set the row background or set a command to an event like you desire. Their suggestion is to use the Cell's mouseclick events to handle it all in code.

My suggestion, if at all possible, is to go back to WPF 4.0's DataGrid and bind to an ICollectionView to utilize it's Filtering function. Linked are many of Bea Stollnitz' tutorials on manipulating collection views.

Mattias

Have you had a look at the CellFactory class and ICellFactory interface. I used this to set different backgroundcolors depending of the item status in one of my projects.

Public Overrides Sub CreateCellContent(grid As C1.WPF.FlexGrid.C1FlexGrid, bdr As Border, rng As C1.WPF.FlexGrid.CellRange)
        MyBase.CreateCellContent(grid, bdr, rng)

        Dim infPre As InfPresenterTextEntity
        infPre = CType(grid.Rows(rng.Row).DataItem, InfPresenterTextEntity)

        If Not infPre Is Nothing Then
            If infPre.IsNew Then
                grid.Rows(rng.Row).Background = Brushes.LightGreen
            ElseIf infPre.IsDirty Then
                grid.Rows(rng.Row).Background = Brushes.LightYellow
            End If

            'grid.AutoSizeRow(rng.Row, 0)
            'grid.AutoSizeRows(rng.Row, rng.Row, 0)
        End if 
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!