Results 1 to 40 of 1650

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

Threaded View

  1. #11
    Member
    Join Date
    Mar 2020
    Location
    Germany (BW)
    Posts
    49

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    I changed the ColPosition/RowPosition as follows (quick and dirty):
    Code:
    Public Property Let ColPosition(ByVal Index As Long, ByVal Value As Long)
    If (Index < 0 Or Index > (PropCols - 1)) Or (Value < 0 Or Value > (PropCols - 1)) Then Err.Raise Number:=381, Description:="Subscript out of range"
    If Index = Value Then Exit Property
    'Bisher:
    Dim i As Long, Swap1 As TCELL, Swap2 As TCOLINFO
    On Error Resume Next
    
    'For i = 0 To (PropRows - 1)
    '    With VBFlexGridCells.Rows(i)
    '    LSet Swap1 = .Cols(Index)
    '    LSet .Cols(Index) = .Cols(Value)
    '    LSet .Cols(Value) = Swap1
    '    End With
    'Next i
    'LSet Swap2 = VBFlexGridColsInfo(Index)
    'LSet VBFlexGridColsInfo(Index) = VBFlexGridColsInfo(Value)
    'LSet VBFlexGridColsInfo(Value) = Swap2
    
    'SeniorChef...
    Dim nCol&
    If Index < Value Then
       
       For i = 0 To PropRows - 1
          With VBFlexGridCells.Rows(i)
             LSet Swap1 = .Cols(Index)
             For nCol = Index To Value - 1
                LSet .Cols(nCol) = .Cols(nCol + 1)
             Next
             LSet .Cols(Value) = Swap1
          End With
       Next
       LSet Swap2 = VBFlexGridColsInfo(Index)
       For nCol = Index To Value
          LSet VBFlexGridColsInfo(nCol) = VBFlexGridColsInfo(nCol + 1)
       Next
       LSet VBFlexGridColsInfo(Value) = Swap2
       
    ElseIf Index > Value Then
       For i = 0 To PropRows - 1
          With VBFlexGridCells.Rows(i)
             LSet Swap1 = .Cols(Index)
             For nCol = Index To Value + 1 Step -1
                LSet .Cols(nCol) = .Cols(nCol - 1)
             Next
             LSet .Cols(Value) = Swap1
          End With
       Next
       LSet Swap2 = VBFlexGridColsInfo(Index)
       For nCol = Index To Value Step -1
          LSet VBFlexGridColsInfo(nCol) = VBFlexGridColsInfo(nCol - 1)
       Next
       LSet VBFlexGridColsInfo(Value) = Swap2
    End If
    'End SeniorChef
    
    
    Dim RCP As TROWCOLPARAMS
    With RCP
    .Mask = RCPM_LEFTCOL
    .Flags = RCPF_CHECKLEFTCOL Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
    .LeftCol = VBFlexGridLeftCol
    Call SetRowColParams(RCP)
    End With
    End Property
    
    Public Property Let RowPosition(ByVal Index As Long, ByVal Value As Long)
    If (Index < 0 Or Index > (PropRows - 1)) Or (Value < 0 Or Value > (PropRows - 1)) Then Err.Raise Number:=381, Description:="Subscript out of range"
    If Index = Value Then Exit Property
    Dim Swap As TCOLS
    'bisher:
    'With VBFlexGridCells
    'LSet Swap = .Rows(Index)
    'LSet .Rows(Index) = .Rows(Value)
    'LSet .Rows(Value) = Swap
    'End With
    
    'SeniorChef:
    With VBFlexGridCells
    LSet Swap = .Rows(Index)
    Dim nRow&
    If Index < Value Then
       For nRow = Index To Value - 1
          LSet .Rows(nRow) = .Rows(nRow + 1)
       Next
    ElseIf Index > Value Then
       For nRow = Index To Value + 1 Step -1
          LSet .Rows(nRow) = .Rows(nRow - 1)
       Next
    End If
    LSet .Rows(Value) = Swap
    End With
    'End SeniorChef
    
    Dim RCP As TROWCOLPARAMS
    With RCP
    .Mask = RCPM_TOPROW
    .Flags = RCPF_CHECKTOPROW Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
    .TopRow = VBFlexGridTopRow
    Call SetRowColParams(RCP)
    End With
    End Property
    Last edited by Seniorchef; Jun 8th, 2022 at 05:01 AM. Reason: Sorry, checking the bounds was wrong and VBFlexColsInfo were not moved

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