Datagrid data row color in color in WinCE

how can i draw all rows in a datagrid with the field value "age" = 30 in red?

I work in WinCE.

Thanks for any help!

0
source share
2 answers

try something like. I have installed

Datagrid1.Datasource = Datatable1.DefaultView

where Datatable1 is a Datatable that contains a column named "Age"

Sorry, is in VB

Private Sub paintColors ()

  Dim vI As Int64 DataGrid1.SelectionBackColor = Color.OrangeRed Dim vI As Int64 = 0 For vI = 0 To Datatable1.DefaultView.Count - 1 If Datatable1.DefaultView.Item(vI)("Age") = 30 Then DataGrid1.Select(vI) Else DataGrid1.UnSelect(vI) End If Next 

End Sub

+1
source

I would advise returning to the ctacke example related to and, in particular, looking at:

 DataGridCustomColumnBase.DrawBackground 

There, he supports coloring the string in a specific color for alternate strings. Once you understand this in her enthusiasm , it should not be too difficult to paint them in whatever color you want, whenever you want. p>

The sample code is so amazing that you can play with the full framework and then transfer your knowledge (since the guy made his code cross-compatible with CF ↔ FF) with CF. Reread and review this example because it is very nice.

0
source

All Articles