Results 1 to 6 of 6

Thread: Color cell with MSFLEXGrid! Pls help me!

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    VietNam
    Posts
    35

    Color cell with MSFLEXGrid! Pls help me!

    Hi all,

    With one value for 1 cell want to set one color. Mean: if me.MSFLEXGrid.textmatrix(col, row)='A' this cell has red color
    elseif me.MSFLEXGrid.textmatrix(col, row)='B' this cell has Blue color. What should I do? Please help me to solve this problem.


    Thanks in advance.
    Chia Voi

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    WELL

    VB Code:
    1. ' THIS EXAMPLE WILL LOOP THRU EACH ROW, BUT ONLY ONE COLUMN
    2.  
    3. Dim IntNext as Integer, IntMax as Integer
    4.  
    5. IntMax = Me.MsflexGrid1.Rows - Me.MsflexGrid1.FixedRows
    6.  
    7. For IntNext = 1 to IntMax
    8.  
    9.     Me.MsFlexGrid1.Col = 1
    10.  
    11.     Me.MsFlexGrid1.Row = IntNext
    12.  
    13.     Select Case Me.MsFlexGrid1.TextMatrix(IntNext,1)
    14.  
    15.     Case "A"
    16.  
    17.         Me.MsFlexGrid1.Row = vbRed
    18.  
    19.     Case "B"
    20.  
    21.         Me.MsFlexGrid1.Row = vbBlue
    22.  
    23.     End Select
    24.  
    25. ' LOOP TO NEXT ROW
    26.  
    27. Next
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    VietNam
    Posts
    35
    Thanks alot. I try it now!
    Chia Voi

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Originally posted by chiavoi
    Thanks alot. I try it now!
    Hope it helps...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    VietNam
    Posts
    35
    But I got this message:

    "Invalid Row value". Is there another way? Or I made sone thing wrong. This is my code:


    strS = ""
    strS = "select * from RoomNo"
    Call ados.Open(strS, cnn, adOpenKeyset, adLockOptimistic)
    If Not ados.EOF And Not ados.BOF Then
    i = 1
    ados.MoveFirst
    While Not ados.EOF
    Me.msfR.Rows = i + 1
    Me.msfR.Row = i
    If Not IsNull(ados.Fields("RoomNo")) Then
    Me.msfR.TextMatrix(i, 1) = ados.Fields("RoomNo")
    Else
    Me.msfR.TextMatrix(i, 1) = ""
    End If
    For j = 1 To Me.msfR.Cols - 1

    If ados.Fields("Empty") Then
    Me.msfR.Row = vbBlue
    Else
    Me.msfR.Row = vbWhite
    End If
    If ados.Fields("Reser") Then
    Me.msfR.Row = vbGreen
    Else
    Me.msfR.Row = vbWhite
    End If
    If ados.Fields("Lodging") Then
    Me.msfR.Row = vbRed
    Else
    Me.msfR.Row = vbWhite
    End If
    If ados.Fields("Repair") Then
    Me.msfR.Row = vbYellow
    Else
    Me.msfR.Row = vbWhite
    End If
    Next j
    i = i + 1
    ados.MoveNext
    Wend



    Thanks in advance!
    Chia Voi

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Oops try this :

    VB Code:
    1. ' THIS EXAMPLE WILL LOOP THRU EACH ROW, BUT ONLY ONE COLUMN
    2.  
    3. Dim IntNext as Integer, IntMax as Integer
    4.  
    5. IntMax = Me.MsflexGrid1.Rows - Me.MsflexGrid1.FixedRows
    6.  
    7. For IntNext = 1 to IntMax
    8.  
    9.     Me.MsFlexGrid1.Col = 1
    10.  
    11.     Me.MsFlexGrid1.Row = IntNext
    12.  
    13.     Select Case Me.MsFlexGrid1.TextMatrix(IntNext,1)
    14.  
    15.     Case "A"
    16.  
    17.         Me.MsFlexGrid1.CellBackCOlor = vbRed
    18.  
    19.     Case "B"
    20.  
    21.         Me.MsFlexGrid1.CellBackCOlor = vbBlue
    22.  
    23.     End Select
    24.  
    25. ' LOOP TO NEXT ROW
    26.  
    27. Next
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width