?
Solved

DataGrid and Color

Posted on 2003-02-25
3
Medium Priority
?
608 Views
Last Modified: 2012-05-04
What i have is a datagrid with in column(7) a colour such as blue,red and yellow. There are numerous rows in the datagrid. What i would like is to check each column(7) for a colour and change the whole row to that colour! Something like

If DataGrid1.Columns(7) = "Red" Then
DataGrid1.Row.ForeColor = vbRed
End If

It doesnt seem to work
0
Comment
Question by:Briankerr
3 Comments
 

Expert Comment

by:vbprogrammierer
ID: 8017862
Hi,

you can try the following:

set the grid pointer to column 7 with
 datagrid1.col=7
compare color
 if DataGrid1.CellBackColor = vbRed Then    or
 if DataGrid1.CellBackColor = RGB(255,0,0) Then


for changing the whole row color:
(i think the first row is fixed)
With DataGrid1
    .Col = 7
    .Row = 1
    .RowSel = .Rows - 1
    .CellBackColor = <color>
End With

but remember that changing the .Col or .Row fires an EnterCell and LeaveCell

hope this can help you

Dieter
0
 
LVL 2

Accepted Solution

by:
IeuanJ earned 60 total points
ID: 8023714
CellBackColor and RowSel is NOT a VB datagrid property, it is an MS FlexGrid property.  Which you would have to use to alter the background colour of specific cells, DataGrid does not support this functionality as far as I am aware.
0
 

Author Comment

by:Briankerr
ID: 8032951
Looks like you're right!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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
Course of the Month8 days, 15 hours left to enroll

621 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