The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Coloring Rows in the Datagrid Control
Posted: 23 Mar 06 9:49 AM
|
Using the grids CustomDrawCell event. you can specific an entire row to be colored based on a column value. You can also specify only a single cell to be colored (which is really whats happening here).
Thanks to Eugenio's column index function we can access a value from a node. If you want to do altnerating rows (ie, greenbar), there is a commented out section that shows you how. This example is based on a history grid. Thanks to E for pioneering on this one.
Function GetColumnIndexByFieldName ( ByRef Grid, ByVal FieldName ) Dim i Dim lColumnIndex
lColumnIndex = -1 For i = 0 To Grid.Columns.Count - 1 If UCase ( Grid.Columns(i).FieldName ) = UCase ( FieldName ) Then lColumnIndex = i Exit For End If Next GetColumnIndexByFieldName = lColumnIndex End Function
Sub dgColorCustomDrawCell(Sender, ByRef Node, ByRef Column, IsSelected, IsFocused, ByRef Text, ByRef Color, ByRef Alignment, ByRef Font, ByRef FontColor) Dim sFieldName Dim vType Dim lColumnIndex On Error Resume Next 'alternating colored rows 'If Int(Node.Index Mod 2) = 0 Then 'Color = Application.BasicFunctions.StringToColor("Silver") 'End if sFieldName = UCase (Column.FieldName) 'use this if you want to limit which cells are colored 'this will color a row based on the value in the field "A2_TEXT" lColumnIndex = GetColumnIndexByFieldName (dgColor,"A2_TEXT") vType = Node.Values (lColumnIndex) If vType <> "" Then If vType = "Note" Then Color = Application.BasicFunctions.StringToColor ("Red") End If If vType = "Meeting" Then Color = Application.BasicFunctions.StringToColor ("Yellow") End if If vType = "To-Do" Then Color = Application.BasicFunctions.StringToColor ("Silver") End if If vType = "Phone Call" Then Color = Application.BasicFunctions.StringToColor ("Aqua") End if End If End Sub
|
|
|
| |
| |
|
Re: Coloring Rows in the Datagrid Control
Posted: 23 Mar 06 12:20 PM
|
fiogf49gjkf0d Yeah, this is a great trick. Just awesome. I mentioned to Eugenio that it would be great on this site and he's promised me a full article detailing the steps.
Thanks for the post Mike. BTW, you can post images, but you just have to have to place them on your own server and then add an img tag to them. The posts do allow some markup, but obviously not script tags and other annoying ort harmful tags.
-Ryan |
|
|
| |
|
Re: Coloring Rows in the Datagrid Control
Posted: 24 Mar 06 9:21 AM
|
symbicort vs advair price symbicort vs advair vs breo open fiogf49gjkf0d It's great to hear that we can do this in 6.2.3 I tried to get it to work in 6.2.2 with no success...even using the controls from DevExpress. I had to use an external .net app
You can display different editors in the same column based on the value of a field as well using the CustomNodeCellEdit event
Private Sub treeList2_GetCustomNodeCellEdit(ByVal sender As Object, ByVal e As DevExpress.XtraTreeList.GetCustomNodeCellEditEventArgs) Handles TreeList2.CustomNodeCellEdit
If e.Node.Item(TreeList2.Columns.ColumnByName("serialized")) = 0 Then e.RepositoryItem = RepositoryItemButtonEdit1 Else e.RepositoryItem = RepositoryItemComboBox2 End If
End Sub |
|
|
|
Re: Coloring Rows in the Datagrid Control
Posted: 24 Mar 06 9:25 AM
|
can i buy abortion pill online can i buy the abortion pill over the counter fiogf49gjkf0d You're speaking of the Quantim Grid, right? I was talking about the SLX grid that is based on the Quantum grid |
|
|
|
Re: Coloring Rows in the Datagrid Control
Posted: 24 Mar 06 9:34 AM
|
fiogf49gjkf0d Yes, I was referring to the Quantum grid from DevExpress. (and Quantum treelist and the .net equivalents) When I use the Quantum grid in SL 6.2.2, it lists the custom draw events in Architect, but SL never raises the events.
|
|
|
|