Results 1 to 11 of 11

Thread: Coloring MXFlexGrid

  1. #1

    Thread Starter
    Addicted Member hyousuf2's Avatar
    Join Date
    Dec 2004
    Location
    Dublin
    Posts
    226

    Coloring MXFlexGrid

    how do i change the background color of different rows in a MXFlexGrid ?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Coloring MXFlexGrid

    Hi hyousuf2 and welcome to VBFORUMS.
    Give it a try to this sample and let me know:
    VB Code:
    1. With MXFlexGrid1
    2.         For i = 1 To .Rows
    3.             If i Mod 2 = 0 Then
    4.                 For j = 0 To .Cols - 1
    5.                     .Row = i
    6.                     .Col = j
    7.                     .CellBackColor = vbYellow
    8.                 Next j
    9.             Else
    10.                 For j = 0 To .Cols - 1
    11.                     .Row = i
    12.                     .Col = j
    13.                     .CellBackColor = vbGreen
    14.                 Next j
    15.             End If
    16.         Next i
    17.     End With

  3. #3

    Thread Starter
    Addicted Member hyousuf2's Avatar
    Join Date
    Dec 2004
    Location
    Dublin
    Posts
    226

    Re: Coloring MXFlexGrid

    hi rhinobull, that code worked well, jus tell me one more thing. how do i assign custom colors other than vbGreen or vbYellow e.t.c

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Coloring MXFlexGrid

    Open your form in design and go to properties. Select Backcolor and choose any color you want. Then just copy that value from properties window and paste it to replace any of those colors I used in my sample. Do the same thing for the second color but don't forget to reset your form's backcolor to whatever it was.

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Coloring MXFlexGrid

    Here is a sample of custome colors:
    VB Code:
    1. With HFGrid
    2.         For i = 1 To .Rows - 1
    3.             If i Mod 2 = 0 Then
    4.                 For j = 0 To .Cols - 1
    5.                     .Row = i
    6.                     .Col = j
    7.                     .CellBackColor = &HE1F9FF   'lite yellow
    8.                 Next j
    9.             Else
    10.                 For j = 0 To .Cols - 1
    11.                     .Row = i
    12.                     .Col = j
    13.                     .CellBackColor = &HC5CEFE   'light red
    14.                 Next j
    15.             End If
    16.         Next i
    17.     End With

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Coloring MXFlexGrid

    I would recommend that you create CONSTANTS in some module for these custom colors. Searching around for values in code later on, when you want to change colors - is a pain.

    We actually use GLOBAL VARIABLES - so that the colors could potentially be different from user to user - haven't actually implemented that yet, but using GLOBAL VARIABLES will allow us to.

    Also, be careful about what colors you choose. Some monitors, video cards, and especially projectors, do not represent colors exactly the same. In our shop we stick to simple colors - either the 8 that VB offer, or ramp up to the extra 8 you get with QBCOLOR. Just to keep it simple...

    Top of some module...

    Code:
    Public gColorDirtyGrid As Long
    Public gColorCleanGrid As Long
    Public gColorHotBox As Long
    Public gColorHighLight As Long
    Public gColorDirty As Long
    Public gColorClean As Long
    Public gColorLetter As Long
    Public gColorMatch As Long
    Public gColorMatchLetter As Long
    In our MDI Parent Form Load event...

    Code:
        gColorHotBox = QBColor(11)      ' vbCyan
        gColorDirtyGrid = QBColor(7)    ' White
        gColorHighLight = QBColor(14)   ' vbYellow / Light Yellow
        gColorDirty = QBColor(10)       ' vbGreen / Light Green
        gColorClean = QBColor(15)       ' vbWhite / Bright White
        gColorMatch = QBColor(5)        ' Magenta
        gColorMatchLetter = QBColor(14) ' vbYellow / Light Yellow
        gColorLetter = vbBlack

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Coloring MXFlexGrid

    I agree: declaring at the module level some color consts will be a big help down the road, however you still have to find those that you believe are the ones and also neither VB nor QBColor offer any decent color range so working with true colors palette is what I recommend.
    In the old days when computer video cards weren't really that great using true colors could be very problematic but these nova days it's totally safe.

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Coloring MXFlexGrid

    Quote Originally Posted by RhinoBull
    I agree: declaring at the module level some color consts will be a big help down the road, however you still have to find those that you believe are the ones and also neither VB nor QBColor offer any decent color range so working with true colors palette is what I recommend.
    In the old days when computer video cards weren't really that great using true colors could be very problematic but these nova days it's totally safe.
    We sell software to school districts - they have no money to upgrade old computers - you would be surprised at what we encounter for old PC's and monitors - running 800x600 (and even less sometimes)...

    We also have some nice commercial customers - flat screen LCD monitors...

    Quite a stretch to support...

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Coloring MXFlexGrid

    Yea, you could be right. As a matter of fact the friend of mine supports small business that has few 486s and a couple of P1-160 ...

  10. #10

    Thread Starter
    Addicted Member hyousuf2's Avatar
    Join Date
    Dec 2004
    Location
    Dublin
    Posts
    226

    Re: Coloring MXFlexGrid

    well thnkx mr rhino bull but actually i posted that reply abt a day back n u dintt reply dats y i had to post an extra thread. but neva da less i have really got ur details workin now !

  11. #11
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Coloring MXFlexGrid

    "Extra tread" doesn't usualy help much - it's nothing more but a way to overload board with identical questions rather than just wait for proper respond in the original.
    But I'm glad that you've managed to have it working.

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