dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Change a FlexGrid Row Back Color

  1. #1
    Join Date
    Aug 2010
    Posts
    17

    Change a FlexGrid Row Back Color

    Dear Friends,

    I have developed a letter management system for my office. And I have installed into 10 systems. In that 2 persons are administrator and remaining 8 persons are section peoples. They are authorise person to send comments to section.

    Initially if a letter came, corresponding section add letter details in s/w. And When administrator see that, if he wish to ask any query or comments from section, he may update that record using letter ID. Now they wish to seperate (set Color) for a particular letter which they put comments or queries.
    Then section people came to know that administrator asking query for that particular letter.

    I am enclosing herewith a screenshot for your kind perusal. This screen is displaying for both section and administrator.

    If administrator update any one letter, that letter should be shown seperately in grid by its color (Row BackColor). The same grid showing by section also. So its easy for follow up. For that I need idea from your end and how to set a backcolor for a particular row. After updation from section, it must change to normal.

    I hope that you can understand my needs.

    Thanks in advance.

    Yours
    GUNA
    Attached Images Attached Images  

  2. #2
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,323

    Re: Change a FlexGrid Row Back Color

    If I remember correctly you use code to select the cells in the row you want to change and then set the selection backcolor. I did this a while back but it is fuzzy now. I had a customer that wanted a timer on how long it took to fill orders and for ones that were taking longer than thier target the row would turn red and the text would flash. Wasn't that hard to do once I found the correct methods.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    149

    Re: Change a FlexGrid Row Back Color

    As mentioned by DataMiser, you can change the background color of a cell and the row. If you want to change all the cells of a particular row, you have to loop through all the columns.

    Below code may take you in the right direction.
    Code:
    Private Sub SetBackColor(FlexGrid As MSHFlexGrid, RowNo As Integer, BkColor As ColorConstants)
        Dim ColCount As Integer
        With FlexGrid
            If RowNo >= .Rows Then
                MsgBox "Invalid RowNo"
            End If
            .Row = RowNo
            For ColCount = .FixedCols To .Cols - 1
                .Col = ColCount
                .CellBackColor = BkColor
            Next
        End With
    End Sub
    Good Luck
    Encourage the efforts of fellow members by rating

    Lets not Spoon Feed and create pool of lazy programmers

    - ComIT Solutions

  4. #4
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,323

    Re: Change a FlexGrid Row Back Color

    The method above will work just fine but it will be faster if you select the cells abd then change the color of the selection.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    149

    Re: Change a FlexGrid Row Back Color

    Quote Originally Posted by DataMiser View Post
    The method above will work just fine but it will be faster if you select the cells abd then change the color of the selection.
    I Agree DataMiser, the same code can be modified as below:
    Code:
    Private Sub SetBackColor(FlexGrid As MSHFlexGrid, RowNo As Integer, BkColor As ColorConstants)
        With FlexGrid
            If RowNo >= .Rows Then
                MsgBox "Invalid RowNo"
            End If
            .FillStyle = flexFillRepeat '<----Without this line it will not work
            
            .Row = RowNo
            .Col = .FixedCols
            
            .RowSel = RowNo
            .ColSel = .Cols - 1
            
            .CellBackColor = BkColor
        End With
    End Sub
    Encourage the efforts of fellow members by rating

    Lets not Spoon Feed and create pool of lazy programmers

    - ComIT Solutions

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)