Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1527
  • Last Modified:

SSDBGrid: change color of a cell

I'm using SSDBGrid to display data. I wanna change color (backcolor and forecolor) of the cells which meet some conditions (eg. quantity exceed 100). Could any body show me how to change the color of a cell?

Thanks a bunch
nguyenn
0
nguyenn
Asked:
nguyenn
1 Solution
 
rkot2000Commented:

you need to create a StyleSets (where you can set backcolor, forecolor, and ....)in the grid

"24Hours", "ActiveColumn" - names for the style set

and use the following event to change color:

Private Sub DBGridSelect_RowLoaded(ByVal Bookmark As Variant)
Dim i As Integer

  If DateDiff("d", Format(DBGridSelect.Columns("Date Received").Text, "mm/dd/yyyy"), Now) > 1 Then
    For i = 0 To DBGridSelect.Cols - 1
      DBGridSelect.Columns(i).CellStyleSet "24Hours"
    Next i
  Else
    For i = 0 To DBGridSelect.Cols - 1
      DBGridSelect.Columns(i).CellStyleSet "ActiveColumn"
    Next i
  End If

End Sub
0
 
nguyennAuthor Commented:
Thanks rkot2000, your help is very appreciated

nguyenn
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now