Results 1 to 4 of 4

Thread: Problem after applying Alternate Row Colr of FlexGrid

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Quetta-Pakistan
    Posts
    852

    Problem after applying Alternate Row Colr of FlexGrid

    Hi,

    I am facing a problem after applying the Alternate Row Color Code in VB, My Flex grid do not show the Focus Rectangle. The Alternate Row Color Code is as under

    Code:
    Public Sub GridColors(ColorGrid As MSHFlexGrid)
        For j = 0 To ColorGrid.Cols - 1
            For i = 1 To ColorGrid.Rows - 1
                If i Mod 2 = 1 Then
                    ColorGrid.Col = j
                    ColorGrid.Row = i
                    ColorGrid.CellBackColor = RGB(mRed, mGreen, mBlue)
                End If
            Next i
        Next j
    End Sub
    Please help

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Problem after applying Alternate Row Colr of FlexGrid

    I tried your code and the focus rectangle did not disappear when I ran it. Are you sure the FocusRect property isn't set to flexFocusNone?

    You may optimize your For loops like this:

    Code:
    Option Explicit
    
    Public Sub GridColors(ByRef ColorGrid As MSHFlexGrid)
        Dim i As Long, j As Long, Color As OLE_COLOR
    
        Color = RGB(mRed, mGreen, mBlue)
    
        For i = 1& To ColorGrid.Rows - 1& Step 2&
            ColorGrid.Row = i
            For j = 0& To ColorGrid.Cols - 1&
                ColorGrid.Col = j
                ColorGrid.CellBackColor = Color
            Next j
        Next i
    End Sub
    Last edited by Bonnie West; May 20th, 2013 at 11:28 AM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Quetta-Pakistan
    Posts
    852

    Re: Problem after applying Alternate Row Colr of FlexGrid

    Thanks for reply,
    FocusRect is set to 2 (FlexFocusHeavy)
    Secondly my Grid Settings are as under
    Code:
        With fgList
            .Clear
            
            .FixedCols = 0
            .Rows = 1
            .Cols = 2
            
            .ColWidth(0) = 4200
            .ColWidth(1) = 0
            
            .TextMatrix(0, 0) = "Code"
            .TextMatrix(0, 1) = "Description"
        End With

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Problem after applying Alternate Row Colr of FlexGrid

    When I combined your 2nd code with the 1st code, there was only 1 cell visible ("Code"). Of course, it wasn't colored.

    How about you try isolating the root cause by creating a new project and copying your code there little by little. At each step, see whether the FocusRect disappears. If it does, then you know that the latest code you added is causing the problem.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

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