Results 1 to 12 of 12

Thread: [RESOLVED] colour coding or grouping records in Hierarchical Data Grid

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Resolved [RESOLVED] colour coding or grouping records in Hierarchical Data Grid

    I have a HFG as in Pic 1.
    Attachment 96009
    I would like to make it a little easier to see different groups by separating or colour coding them as in the next two pics.
    Attachment 96011Attachment 96013
    Can anyone tell me if it is possible, and if so, how. Thank you.

  2. #2
    gibra
    Guest

    Re: colour coding or grouping records in Hierarchical Data Grid

    Due to doesn't exists a Hierarchical Data Grid control,
    please specific correctly the control you use.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: colour coding or grouping records in Hierarchical Data Grid

    Sorry, FlexGrid, not DataGrid
    Specifically MSHFlexGrid.

  4. #4
    gibra
    Guest

    Re: colour coding or grouping records in Hierarchical Data Grid

    So, you had moved from DataGrid to MSHFlexGrid ?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: colour coding or grouping records in Hierarchical Data Grid

    Yes, that's right.

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: colour coding or grouping records in Hierarchical Data Grid

    This is ONE WAY how to color the background of individual cells (rows) in a flexgrid:

    Code:
         Dim x As Integer, Y as Integer
         For x = 1 To grid1.Rows - 1
            If grid1.TextMatrix(x, 5) = "YES" Then  'In MY example, I color-code columns 0 to 5 of each row where column 5 is a certain value ("YES")
              grid1.Row = x
               For Y = 0 To 5
                   grid1.Col = Y
                   grid1.Row = x
                   grid1.CellBackColor = vbYellow
               Next Y
            End If
         Next x
    You can change the bg color of those particular cells differently depending upon what Group the student is in
    Suggest you use a CASE statement to set a variable for each color you want.

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: colour coding or grouping records in Hierarchical Data Grid

    Keep in mind that this sort of use of color is strongly discouraged by the Windows Development Guidelines for good reason.


    System colors are user controlled, often through accessibility options for low-vision users.

    If you do something whizzy like color a cell yellow (or even explicitly white) then what happens if the system Window Text color turns out to be yellow, white, or another pale color?

    The user won't be able to read the text, that's what.

    And in many countries this can open you to a lawsuit over impaired accessibility.


    Just don't do this. Even if you carefully set both background and foreground colors you can be in violation of the laws by overriding the user's accessibility settings.

  8. #8
    gibra
    Guest

    Re: colour coding or grouping records in Hierarchical Data Grid

    Quote Originally Posted by dilettante View Post
    Keep in mind that this sort of use of color is strongly discouraged by the Windows Development Guidelines for good reason.


    System colors are user controlled, often through accessibility options for low-vision users.

    If you do something whizzy like color a cell yellow (or even explicitly white) then what happens if the system Window Text color turns out to be yellow, white, or another pale color?

    The user won't be able to read the text, that's what.

    And in many countries this can open you to a lawsuit over impaired accessibility.


    Just don't do this. Even if you carefully set both background and foreground colors you can be in violation of the laws by overriding the user's accessibility settings.
    I agree 100%.

    I Add: use with caution, because if you use formula to calculate something (totals, averages, ...) on LeaveCell/EnterCell events, then each time you change Row/Col events will be fired.
    Because on flexgrid doesn't exists a method like SetBackColor(x,y) or SetForeColor(x,y), therefore (as SamOscarBrows shows to you) you need each time change Row adn Col property.

    If so, set Redraw to False before, and set to True after changing color.
    Eventually, see also se FillStyle property for apply color to a range of cells.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: colour coding or grouping records in Hierarchical Data Grid

    Quote Originally Posted by dilettante View Post
    Just don't do this.
    Very interesting information, thank you. However, for me, in this situation, it is not a problem because the app is for my own personal use in my school.
    Saying that, it would be nice to conform to legal guidelines (if in the future some fool wanted to buy my app). Given that, do you know of any way to leave a space between the records with different groups as per pic3 above.
    Or, alternatively, Put a thicker border on the cells when the group changes?
    Basically, I want some way to make it easy to identify at a glance, the students belonging to different groups because group names would be something like:
    1A
    1B
    2A
    3A
    4A
    4B

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: colour coding or grouping records in Hierarchical Data Grid

    One easy way is to use a 'space' (blank row) between groups. As you are moving through your recordset, (needs to be sorted by groupname), each time groupname changes, make the cells in the next row = blank ("").

  11. #11
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: colour coding or grouping records in Hierarchical Data Grid

    @Dile...was not aware of this 'color/colour warning'. Interesting. Maybe I oughta read more. I guess bolding/unbolding could work for OP, or even font size changes. How would YOU attack something like what OP wants to do?---make it stand out somehow for each group.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: colour coding or grouping records in Hierarchical Data Grid

    Since no "better" solution is forthcoming, I will go with Sam's Colour coding. Thank you once again Sam.

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