Question : VB6 MSFlexgrid in color if

Hello all,

I would like to put the row in gray color if the text in column 2 and column 3 on the same row are the equal.

For ex: if on row 6, the text in column 2 = 10 and the text in column 3 = 10, then it will put the row 6 in a gray color.

How can i do that please?

Thanks for your help.

Answer : VB6 MSFlexgrid in color if

I think you may need a easier to understand solution to start with. This may help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
Dim intRow As Integer
Dim intCol As Integer

Dim strColumn2 As String
Dim strColumn3 As String 

For intRow = 0 To MSFlexGrid1.Rows - 1
    
    '// Set the row    
    MSFlexGrid1.Row = intRow

    '// Check if the row is 6?
    If intRow = 6 Then

        '// Capture column 2 content
        MSFlexGrid1.Col = 2
        strColumn2 = MSFlexGrid1.Text    
    
        '// Capture column 3 content
        MSFlexGrid1.Col = 3
        strColumn3 = MSFlexGrid1.Text

        If strColumn2 = "10" And strColumn3 = "10" Then
    
            '// Loop through each column and change the backcolor
            For intCol = 0 to MSFlexGrid1.Cols - 1
                MSFlexGrid1.Col = intCol
                MSFlexGrid1.CellBackColor = vbGray '// Or any color
            Next

        End If

    End If

Next
Random Solutions  
 
programming4us programming4us