Solved

SSDBGrid: change color of a cell

Posted on 2001-07-09
2
1,455 Views
Last Modified: 2007-11-27
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
Comment
Question by:nguyenn
2 Comments
 
LVL 5

Accepted Solution

by:
rkot2000 earned 100 total points
ID: 6265415

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
 
LVL 1

Author Comment

by:nguyenn
ID: 6265466
Thanks rkot2000, your help is very appreciated

nguyenn
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question