MSFlexGrid - Highlight specific rows 
Author Message
 MSFlexGrid - Highlight specific rows

Hello,

I am trying to pull data from a database, and depending on
one field "ResolvedDate", would like to distinguish
between the ones that have a resolved date, and the ones
that do not.

Each row comes in individually through a class in the
application. As each row comes in, I check for
the "ResolvedDate" with an if statement.

I have tried grid.Highlight, which is just the color of
the currently selected row.

I have tried grid.cellBackColor, but it only works with
selected cells.

Is there a way to change the back color of, preferrably a
row but at least the first cell, of multiple rows, while
not necessarily selecting them?

Hope that is clear, thank you,
Denny



Sat, 17 Dec 2005 00:23:32 GMT  
 MSFlexGrid - Highlight specific rows

released on Mon, 30 Jun 2003 09:23:32 -0700 bearing the
following fruit:

Quote:
>Hello,

>I am trying to pull data from a database, and depending on
>one field "ResolvedDate", would like to distinguish
>between the ones that have a resolved date, and the ones
>that do not.

>Each row comes in individually through a class in the
>application. As each row comes in, I check for
>the "ResolvedDate" with an if statement.

>I have tried grid.Highlight, which is just the color of
>the currently selected row.

>I have tried grid.cellBackColor, but it only works with
>selected cells.

Which is exactly what you want. If fillstyle is set to
repeat then you can set a row, or whole block of cells in
one go.

Quote:
>Is there a way to change the back color of, preferrably a
>row but at least the first cell, of multiple rows, while
>not necessarily selecting them?

As above. Set .Row, .Col and .ColSel then set the
backcolour, if FillStyle is set to repeat it will colour the
whole line.

eg.

.Row = 10
.Col = .FixedCols
.Cols = .Cols-1
.CellBackColor = vbred

J

--
Becoming a locksmith turned out to be his key to success.  (Jumble)

[Abolish the TV Licence - http://www.tvlicensing.biz/]



Sat, 17 Dec 2005 00:31:30 GMT  
 MSFlexGrid - Highlight specific rows
You can always save/restore the col/row settings after changing the color...
'=========
Option Explicit

Private Sub Command1_Click()
   Call SetRowColor(2, vbWhite, vbBlue)
End Sub

Private Sub SetRowColor(WhichRow As Integer _
   , WhatForeColor As OLE_COLOR, WhatBackColor As OLE_COLOR)
   Dim i As Integer
   Dim j As Integer
   Dim k As Integer
   With MSFlexGrid1
      i = .Row
      j = .Col
      .Row = WhichRow
      For k = .FixedCols To .Cols - 1
         .Col = k
         .CellForeColor = WhatForeColor
         .CellBackColor = WhatBackColor
      Next
      .Col = j
      .Row = i
   End With
End Sub

Private Sub Form_Load()
   Dim i As Integer
   Dim j As Integer
   With MSFlexGrid1
      .Clear
      .FixedRows = 1
      .FixedCols = 0
      .Rows = 10
      .Cols = 4
      For i = .FixedRows To .Rows - 1
         .Row = i
         For j = .FixedCols To .Cols - 1
            .Col = j
            .Text = "Row " & i & " Col " & j
         Next
      Next
   End With
End Sub
'=========

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep it in the groups..


Quote:
> Hello,

> I am trying to pull data from a database, and depending on
> one field "ResolvedDate", would like to distinguish
> between the ones that have a resolved date, and the ones
> that do not.

> Each row comes in individually through a class in the
> application. As each row comes in, I check for
> the "ResolvedDate" with an if statement.

> I have tried grid.Highlight, which is just the color of
> the currently selected row.

> I have tried grid.cellBackColor, but it only works with
> selected cells.

> Is there a way to change the back color of, preferrably a
> row but at least the first cell, of multiple rows, while
> not necessarily selecting them?

> Hope that is clear, thank you,
> Denny



Sat, 17 Dec 2005 00:35:07 GMT  
 MSFlexGrid - Highlight specific rows
Jan and Ken - Thank you both :)
Denny

Quote:
>-----Original Message-----

>released on Mon, 30 Jun 2003 09:23:32 -0700 bearing the
>following fruit:

>>Hello,

>>I am trying to pull data from a database, and depending
on
>>one field "ResolvedDate", would like to distinguish
>>between the ones that have a resolved date, and the ones
>>that do not.

>>Each row comes in individually through a class in the
>>application. As each row comes in, I check for
>>the "ResolvedDate" with an if statement.

>>I have tried grid.Highlight, which is just the color of
>>the currently selected row.

>>I have tried grid.cellBackColor, but it only works with
>>selected cells.

>Which is exactly what you want. If fillstyle is set to
>repeat then you can set a row, or whole block of cells in
>one go.

>>Is there a way to change the back color of, preferrably
a
>>row but at least the first cell, of multiple rows, while
>>not necessarily selecting them?

>As above. Set .Row, .Col and .ColSel then set the
>backcolour, if FillStyle is set to repeat it will colour
the
>whole line.

>eg.

>..Row = 10
>..Col = .FixedCols
>..Cols = .Cols-1
>..CellBackColor = vbred

>J

>--
>Becoming a locksmith turned out to be his key to
success.  (Jumble)

>[Abolish the TV Licence - http://www.tvlicensing.biz/]

>.



Sat, 17 Dec 2005 00:40:06 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. need to preselect and highlight row 20 in 6 row unbound msFlexgrid

2. How to highlight a specific row datagrid?

3. MsFlexGrid Control - Highlighting a row

4. How to highlight row in MSFlexgrid

5. highlighting a row in msflexgrid control

6. Programatically Highlight an MSFlexGrid Row

7. How to highlight row in MSflexgrid after search routine

8. Highlighting a MSFlexGrid row

9. programmatically highlighting a row in MSFlexGrid

10. Need to Highlight Row and Column in MSFlexgrid

11. Highlight row in MSFlexgrid?

12. Problem highlighting last row added with MSFlexGrid 6.0

 

 
Powered by phpBB® Forum Software