Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SSDBGrid: change color of a cell

Posted on 2001-07-09
2
Medium Priority
?
1,506 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
rkot2000 earned 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

705 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