?
Solved

Colors in a DBGrid control

Posted on 1998-09-05
5
Medium Priority
?
214 Views
Last Modified: 2010-04-30
Hi,

I need to set a color to a diferents rows, any idea how can I do that. I'll really apreciate your help.
0
Comment
Question by:tulio
[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
5 Comments
 

Expert Comment

by:protogeek
ID: 1433224
Assuming you want to set every other row to be a different color,
how about iterating through the recordset, and determining if it's an even or odd row. Then you can set the background color just for that row.   e.g.

   Dim rst as Recordset
   Dim i as Integer
   For i = 1 To rst.RecordCount
        If (i Mod 2 = 0) Then
           'set the background color
           'I don't have VB on my home system so I don't know
           'the syntax offhand for changing the background prop.
           'of the row
        next i
    End if

0
 

Expert Comment

by:protogeek
ID: 1433225
oops. obviously I switched the End If and next i statements.
0
 

Author Comment

by:tulio
ID: 1433226
I tried to use this code and it change the entire color of the DBGrid background. I need to have diferents row colors depends on a criteria, for instance: All the rows whose CountryCode is "USA" in red and the rest in blue. If you have another solution please let me know ASAP. Thanks one more time for your cooperation.


0
 
LVL 2

Expert Comment

by:shchuka
ID: 1433227
If you are using the DBGrid that came with VB, you can't really do it - all the rows will be the same color.

If you need different rows in different colors, then you need the DBGrid Pro from Apex Software (www.apexsc.com), which allows you that and much, much more...
0
 
LVL 14

Accepted Solution

by:
waty earned 300 total points
ID: 1433228
You can't change the grid of individual rows. You have to use the MSFlexgrid for that purpose.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

765 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