Page 20 of 33 FirstFirst ... 101718192021222330 ... LastLast
Results 761 to 800 of 1320

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

  1. #761
    Member
    Join Date
    Mar 2020
    Location
    Germany (BW)
    Posts
    42

    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

  2. #762
    Member
    Join Date
    Mar 2020
    Location
    Germany (BW)
    Posts
    42

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    BTW, regarding my posts #595 ff I also implemented in my personal vbFlexGrid a method to sort the grid by cols that are not beneath each other, and also mix ascending and descending. It's about 30 lines of code:
    Code:
    'Add Enum 
    Public Enum FlexSortConstants
    ...
    FlexSortUseIndex = 15
    End Enum
    
    'Add Array
    Private FlexGridSortCols() As Long 
    
    'Quick and dirty properties
    Public Property Get SortColIndex(ByVal Index As Long) As Long
       If Index < 0 Or Index > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
       SortColIndex = FlexGridSortCols(Index)
    End Property
    
    'There are better ways to fill the array and check the bounds
    'SeniorChef
    Public Property Let SortColIndex(ByVal Index As Long, ByVal Value As Long)
    If Index <> -1 And (Index < 0 Or Index > (PropCols - 1)) Then Err.Raise Number:=30010, Description:="Invalid SortColIndex value"
    If Value < 0 Or Value > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
    
       'set a value, one after the other, this is not time critical, so redim preserve is ok...
       If Index > -1 Then
          ReDim Preserve FlexGridSortCols(Index)
          FlexGridSortCols(Index) = Value
       Else
          'clear Array
          ReDim FlexGridSortCols(0)
       End If
    End Property
    
    'the improved sort method:
    Public Property Let Sort(ByVal Value As FlexSortConstants)
    
    #If ImplementFlexDataSource Then
    
    If Not VBFlexGridFlexDataSource Is Nothing Then Err.Raise Number:=5, Description:="This functionality is disabled when custom data source is set."
    
    #End If
    
    Select Case Value
    'changes from Seniorchef
    'added FlexSortIndex as a legal Value
    
        Case FlexSortNone, FlexSortGenericAscending, FlexSortGenericDescending, _
             FlexSortNumericAscending, FlexSortNumericDescending, _
             FlexSortStringNoCaseAscending, FlexSortStringNoCaseDescending, _
             FlexSortStringAscending, FlexSortStringDescending, FlexSortCustom, _
             FlexSortUseColSort, FlexSortCurrencyAscending, FlexSortCurrencyDescending, _
             FlexSortDateAscending, FlexSortDateDescending, FlexSortUseIndex
             
            VBFlexGridSort = Value
            If VBFlexGridSort = FlexSortNone Then Exit Property
            
            If (VBFlexGridRow < 0 Or VBFlexGridRowSel < 0) Or (VBFlexGridCol < 0 Or VBFlexGridColSel < 0) Then
                ' Error shall not be raised. Do nothing in this case.
                Exit Property
            End If
            Dim SelRange As TCELLRANGE, iCol As Long, Sort As FlexSortConstants
            Call GetSelRangeStruct(SelRange)
    
    'changes from Seniorchef 
    'Doing the FlexSortIndex-Sort by taking the column to be sorted from the array FlexGridSortCols()
    'rather than using Col and Colsel properties.
    'SeniorChef
            If VBFlexGridSort = FlexSortUseIndex Then
                Dim iIndex As Long
                For iIndex = UBound(FlexGridSortCols) To 0 Step -1
                   iCol = FlexGridSortCols(iIndex)
                   Sort = VBFlexGridColsInfo(iCol).Sort
                   ' MergeSort is used for automatic sorting as it is fast and reliable.
                   If VBFlexGridRow = VBFlexGridRowSel Then
                      Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
                   Else
                      Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
                   End If
                Next iIndex
            Else
    'no more changes 
    
            ' The keys used for sorting are determined by the Col and ColSel properties.
            ' To specify the range to be sorted, set the Row and RowSel properties.
            ' Sorting is always done in a left-to-right direction. (Technically the sorting is performed from right-to-left)
            For iCol = SelRange.RightCol To SelRange.LeftCol Step -1
                If VBFlexGridSort <> FlexSortUseColSort Then Sort = VBFlexGridSort Else Sort = VBFlexGridColsInfo(iCol).Sort
                ' MergeSort/BubbleSort are used as they are 'stable sort' algorithms.
                If Sort <> FlexSortCustom Then
                    ' MergeSort is used for automatic sorting as it is fast and reliable.
                    If VBFlexGridRow = VBFlexGridRowSel Then
                        Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
                    Else
                        Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
                    End If
                Else
                    ' BubbleSort is used for custom sorting as row1/row2 for text matrix must be meaningful in the 'Compare' event.
                    If VBFlexGridRow = VBFlexGridRowSel Then
                        Call BubbleSortIter(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows())
                    Else
                        Call BubbleSortIter(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows())
                    End If
                End If
            Next iCol
            End If
            Dim RCP As TROWCOLPARAMS
            With RCP
            .Mask = RCPM_TOPROW
            .Flags = RCPF_CHECKTOPROW Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
            .TopRow = VBFlexGridTopRow
            End With
            If VBFlexGridIndirectCellRef.InProc = False Then
                Call SetRowColParams(RCP)
            Else
                LSet VBFlexGridIndirectCellRef.RCP = RCP
                VBFlexGridIndirectCellRef.SetRCP = True
            End If
        Case Else
            Err.Raise 380
    End Select
    ' Action-type property. Not real property.
    End Property
    Code:
    'To sort a grid on columns 8, 6, 3, 9:
    With VBFlexGrid
    .sortColIndex(0)=8
    .sortColIndex(1)=6
    .sortColIndex(2)=3
    .sortColIndex(3)=9
    
    'How to sort each column
    .colSort(8)=FlexSortStringNoCaseAscending
    .colSort(6)=FlexSortDateDescending
    .colSort(3)=FlexSortNumericAscending
    .colSort(9)=FlexSortNUmericDescending
    
    'Finally...
    .sort = flexSortUseIndex
    End with
    Feel free to use this in the next update.

    Thanks

  3. #763

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Bugfix in the .RowPosition() and .ColPosition() property. (thanks to Seniorchef for reporting this)

    Now it is a round trip swap instead of a direct swap between index and value.

    This behavior matches now to the MS(H)FlexGrid control.
    Last edited by Krool; Jun 8th, 2022 at 06:57 AM.

  4. #764

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Thanks for your below suggestion. I think it's not necessary.
    The below code would do the same:
    Code:
    With VBFlexGrid1
    .ColSort(8) = FlexSortStringNoCaseAscending
    .ColSort(6) = FlexSortDateDescending
    .ColSort(3) = FlexSortNumericAscending
    .ColSort(9) = FlexSortNumericDescending
    .Cell(FlexCellSort, .FixedRows, 8, .Rows - 1) = FlexSortUseColSort
    .Cell(FlexCellSort, .FixedRows, 6, .Rows - 1) = FlexSortUseColSort
    .Cell(FlexCellSort, .FixedRows, 3, .Rows - 1) = FlexSortUseColSort
    .Cell(FlexCellSort, .FixedRows, 9, .Rows - 1) = FlexSortUseColSort
    End With
    or (alternatively)
    Code:
    With VBFlexGrid1
    .Cell(FlexCellSort, .FixedRows, 8, .Rows - 1) = FlexSortStringNoCaseAscending
    .Cell(FlexCellSort, .FixedRows, 6, .Rows - 1) = FlexSortDateDescending
    .Cell(FlexCellSort, .FixedRows, 3, .Rows - 1) = FlexSortNumericAscending
    .Cell(FlexCellSort, .FixedRows, 9, .Rows - 1) = FlexSortNumericDescending
    End With
    Quote Originally Posted by Seniorchef View Post
    BTW, regarding my posts #595 ff I also implemented in my personal vbFlexGrid a method to sort the grid by cols that are not beneath each other, and also mix ascending and descending. It's about 30 lines of code:
    Code:
    'Add Enum 
    Public Enum FlexSortConstants
    ...
    FlexSortUseIndex = 15
    End Enum
    
    'Add Array
    Private FlexGridSortCols() As Long 
    
    'Quick and dirty properties
    Public Property Get SortColIndex(ByVal Index As Long) As Long
       If Index < 0 Or Index > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
       SortColIndex = FlexGridSortCols(Index)
    End Property
    
    'There are better ways to fill the array and check the bounds
    'SeniorChef
    Public Property Let SortColIndex(ByVal Index As Long, ByVal Value As Long)
    If Index <> -1 And (Index < 0 Or Index > (PropCols - 1)) Then Err.Raise Number:=30010, Description:="Invalid SortColIndex value"
    If Value < 0 Or Value > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
    
       'set a value, one after the other, this is not time critical, so redim preserve is ok...
       If Index > -1 Then
          ReDim Preserve FlexGridSortCols(Index)
          FlexGridSortCols(Index) = Value
       Else
          'clear Array
          ReDim FlexGridSortCols(0)
       End If
    End Property
    
    'the improved sort method:
    Public Property Let Sort(ByVal Value As FlexSortConstants)
    
    #If ImplementFlexDataSource Then
    
    If Not VBFlexGridFlexDataSource Is Nothing Then Err.Raise Number:=5, Description:="This functionality is disabled when custom data source is set."
    
    #End If
    
    Select Case Value
    'changes from Seniorchef
    'added FlexSortIndex as a legal Value
    
        Case FlexSortNone, FlexSortGenericAscending, FlexSortGenericDescending, _
             FlexSortNumericAscending, FlexSortNumericDescending, _
             FlexSortStringNoCaseAscending, FlexSortStringNoCaseDescending, _
             FlexSortStringAscending, FlexSortStringDescending, FlexSortCustom, _
             FlexSortUseColSort, FlexSortCurrencyAscending, FlexSortCurrencyDescending, _
             FlexSortDateAscending, FlexSortDateDescending, FlexSortUseIndex
             
            VBFlexGridSort = Value
            If VBFlexGridSort = FlexSortNone Then Exit Property
            
            If (VBFlexGridRow < 0 Or VBFlexGridRowSel < 0) Or (VBFlexGridCol < 0 Or VBFlexGridColSel < 0) Then
                ' Error shall not be raised. Do nothing in this case.
                Exit Property
            End If
            Dim SelRange As TCELLRANGE, iCol As Long, Sort As FlexSortConstants
            Call GetSelRangeStruct(SelRange)
    
    'changes from Seniorchef 
    'Doing the FlexSortIndex-Sort by taking the column to be sorted from the array FlexGridSortCols()
    'rather than using Col and Colsel properties.
    'SeniorChef
            If VBFlexGridSort = FlexSortUseIndex Then
                Dim iIndex As Long
                For iIndex = UBound(FlexGridSortCols) To 0 Step -1
                   iCol = FlexGridSortCols(iIndex)
                   Sort = VBFlexGridColsInfo(iCol).Sort
                   ' MergeSort is used for automatic sorting as it is fast and reliable.
                   If VBFlexGridRow = VBFlexGridRowSel Then
                      Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
                   Else
                      Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
                   End If
                Next iIndex
            Else
    'no more changes 
    
            ' The keys used for sorting are determined by the Col and ColSel properties.
            ' To specify the range to be sorted, set the Row and RowSel properties.
            ' Sorting is always done in a left-to-right direction. (Technically the sorting is performed from right-to-left)
            For iCol = SelRange.RightCol To SelRange.LeftCol Step -1
                If VBFlexGridSort <> FlexSortUseColSort Then Sort = VBFlexGridSort Else Sort = VBFlexGridColsInfo(iCol).Sort
                ' MergeSort/BubbleSort are used as they are 'stable sort' algorithms.
                If Sort <> FlexSortCustom Then
                    ' MergeSort is used for automatic sorting as it is fast and reliable.
                    If VBFlexGridRow = VBFlexGridRowSel Then
                        Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
                    Else
                        Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
                    End If
                Else
                    ' BubbleSort is used for custom sorting as row1/row2 for text matrix must be meaningful in the 'Compare' event.
                    If VBFlexGridRow = VBFlexGridRowSel Then
                        Call BubbleSortIter(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows())
                    Else
                        Call BubbleSortIter(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows())
                    End If
                End If
            Next iCol
            End If
            Dim RCP As TROWCOLPARAMS
            With RCP
            .Mask = RCPM_TOPROW
            .Flags = RCPF_CHECKTOPROW Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
            .TopRow = VBFlexGridTopRow
            End With
            If VBFlexGridIndirectCellRef.InProc = False Then
                Call SetRowColParams(RCP)
            Else
                LSet VBFlexGridIndirectCellRef.RCP = RCP
                VBFlexGridIndirectCellRef.SetRCP = True
            End If
        Case Else
            Err.Raise 380
    End Select
    ' Action-type property. Not real property.
    End Property
    Code:
    'To sort a grid on columns 8, 6, 3, 9:
    With VBFlexGrid
    .sortColIndex(0)=8
    .sortColIndex(1)=6
    .sortColIndex(2)=3
    .sortColIndex(3)=9
    
    'How to sort each column
    .colSort(8)=FlexSortStringNoCaseAscending
    .colSort(6)=FlexSortDateDescending
    .colSort(3)=FlexSortNumericAscending
    .colSort(9)=FlexSortNUmericDescending
    
    'Finally...
    .sort = flexSortUseIndex
    End with
    Feel free to use this in the next update.

    Thanks

  5. #765
    Member
    Join Date
    Mar 2020
    Location
    Germany (BW)
    Posts
    42

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Yep - the results seem the same.
    It's really hard to know all the possibilities of the control.
    Thank's for your efforts in this point.
    And of course thank's for the control!
    Regards

  6. #766
    New Member
    Join Date
    Apr 2022
    Posts
    4

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Use RemoveItem ,Wheel will invalid!
    please fix it !

  7. #767

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by fengzhongxia View Post
    Use RemoveItem ,Wheel will invalid!
    please fix it !
    Please more context.

  8. #768
    Member
    Join Date
    Apr 2021
    Posts
    44

    Exclamation Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Mr. Krool, why don't you use the files that I shared? Progress cells, chart cells, and many other things would have already been done. I hope you reconsider, thanks

  9. #769

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by fengzhongxia View Post
    Use RemoveItem ,Wheel will invalid!
    please fix it !
    Update released. Fixed.

  10. #770

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Bugfix for FlexFocusRectFlat. The pen style uses now a NULL_BRUSH to not affect custom background color/picture.

  11. #771
    New Member
    Join Date
    Dec 2020
    Posts
    14

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Love the CellComboCue. Question - is there a way for this to be persistent in a cell? My understanding is that it is a dynamic cue on a cell event. We are considering the case of new users that might benefit from the persistent visual cue of the dropdown button. Thanks!

  12. #772

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by TheLeePiper View Post
    Love the CellComboCue. Question - is there a way for this to be persistent in a cell? My understanding is that it is a dynamic cue on a cell event. We are considering the case of new users that might benefit from the persistent visual cue of the dropdown button. Thanks!
    It can be dynamic or persistent. Both ways are possible.
    ComboCue/ComboCueRow/Col are dynamic.
    CellComboCue is persistent. Best way to FillStyle that for whole Column via .Cell property (virtual selection)

  13. #773
    New Member
    Join Date
    Dec 2020
    Posts
    14

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Got it. Fantastic. Thanks so much for the assist and your efforts at large.

  14. #774
    New Member
    Join Date
    Dec 2020
    Posts
    14

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Question regarding the ComboDropDown function. I have set up a cell as a DropDown with the Cue working great. If I click the body of the cell, it properly drops the list, and grid.Row correctly is the current grid row of the DropDown cell. However, if I drop the list using the button itself, grid.Row is the previously entered grid row (and not the DropDown grid row). Is this the expected behavior? (Also note that the ValidateEdit function is also subsequently fired with the correct grid.Row in both cases.)

    Additionally, if I click on the list item that is the current ComboListIndex, neither of these evens are fired. For example, say I have a list A & B, and A was previously selected. If I select A again, the events are not fired. If I select B, they are fired. Expected behavior? (This is less of an issue because data doesn't change, but it is curious that the events didn't fire.)

    Thanks!

  15. #775

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by TheLeePiper View Post
    Question regarding the ComboDropDown function. I have set up a cell as a DropDown with the Cue working great. If I click the body of the cell, it properly drops the list, and grid.Row correctly is the current grid row of the DropDown cell. However, if I drop the list using the button itself, grid.Row is the previously entered grid row (and not the DropDown grid row). Is this the expected behavior? (Also note that the ValidateEdit function is also subsequently fired with the correct grid.Row in both cases.)

    Additionally, if I click on the list item that is the current ComboListIndex, neither of these evens are fired. For example, say I have a list A & B, and A was previously selected. If I select A again, the events are not fired. If I select B, they are fired. Expected behavior? (This is less of an issue because data doesn't change, but it is curious that the events didn't fire.)

    Thanks!
    Yes, grid.Row is the current focused cell. If you click the combo cue, the focus doesn't change. So, you might use the grid.EditRow function.
    The ValidateEdit event is fired only when the text has changed, that's by design. It's an event to validate changes.
    You might check the LeaveEdit or AfterEdit event if that fits your needs.

  16. #776
    New Member
    Join Date
    Dec 2020
    Posts
    14

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Understood, thanks!

  17. #777

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Included the Copy/Cut/Paste/Delete method. This is just a simple wrapper to put .Clip property to the clipboard or set the .Clip property from the clipboard.

    Also included the ClipCopyMode property. 0 - Normal and 1 - IncludeFixedRows for the moment only.
    This value affects the Copy method and the Clip Get-Property. (not the Clip Let-Property)
    To have Clip Get/Let property to behave the same keep it as 0 - Normal. (default)
    Last edited by Krool; Nov 11th, 2022 at 08:38 AM.

  18. #778
    Addicted Member
    Join Date
    Nov 2016
    Location
    GB
    Posts
    141

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    I need in one of my projects to write normal text and bold text within the same grid cell, or texts of different colors. Does your Vbflexgrid allow it?

  19. #779
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,871

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    No it does not support in-cell markup.
    All font styles apply to the complete cell.

  20. #780

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Included the ClipSeparatorCol/ClipSeparatorRow run-time property.
    These properties expose the default separators vbTab and vbCr. Thus the defaults can be changed.
    Also, it provides a way to support more than 1 character for a separator.
    This may be useful for the row separator vbCrLf to better exchange with MS Excel.

    However, for back-compatibility. If the ClipSeparators property is set, then that will be used.
    But that is consistent, if ClipSeparators is empty the defaults are used. (ClipSeparatorCol/ClipSeparatorRow)
    ClipSeparators is just limited to 1 character per separator.

    So, during a Form_Load one can change the default value:
    Code:
    VBFlexGrid1.ClipSeparatorRow = vbCrLf

  21. #781

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Included Delete method. Also Cut/Paste/Delete method will scroll to the current cell, if necessary. (CellEnsureVisible)

    Included AutoClipboard property.
    Last edited by Krool; Nov 16th, 2022 at 02:15 AM.

  22. #782

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Minor bugfix for the ShowLabelTips property. The cell text was considered falsely as "folded" in case the cell rect was partially clipped by the border of the client rect.
    That resulted in showing the label tooltip when in fact the text was fully visible.

    The 1.5 OCX was also updated with this fix.
    Last edited by Krool; Nov 26th, 2022 at 05:42 AM.

  23. #783
    New Member
    Join Date
    Nov 2022
    Posts
    1

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Thank You for Your great job!

    By the way, I can't find any documentation or some description of the functions and its parameters... Do You have plans for it? It would be very useful!

    Thanks!

  24. #784

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Updated released.

    Included the cell flooding feature to display like a progress bar in cells. (CellFloodPercent/CellFloodColor/FloodColor property)
    Like in the vsFlexGrid a positive FloodPercent will be from left to right and a negative from right to left.

    Also added enum FlexCellFloodPercent and FlexCellFloodColor to enrich the Cell property.

  25. #785

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    The Checkboxes feature is now included via the CellChecked property.

    Name:  FlexCheckBox.png
Views: 845
Size:  11.9 KB

    The new events CellBeforeCheck/CellCheck event helps to react to user interaction.
    These are not fired by code, only by mouse click or the space key.

    New hit result enum FlexHitResultCheckBox for obvious reason.

    The alignment of the checkbox can be either left-center, center-center or right-center and is linked to the CellPictureAlignment property. (!)

  26. #786
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    597

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    It can be dynamic or persistent. Both ways are possible.
    ComboCue/ComboCueRow/Col are dynamic.
    CellComboCue is persistent. Best way to FillStyle that for whole Column via .Cell property (virtual selection)
    Can we have an option to have HotTracking, Specifically for Cue button? By doing so, the Cue is lively interaction.
    Attached Images Attached Images  

  27. #787

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by DaveDavis View Post
    Can we have an option to have HotTracking, Specifically for Cue button? By doing so, the Cue is lively interaction.
    The Combo button is already hot-tracked. But yes, the combo cue isn't as it's drawn built in by the grid.
    So, yes. I wouldn't want to have mouse track on by default always for the grid itself.
    Thus having a new "HotTracking" property would be ideal.
    If set to true, all checkboxes and combo cues are being drawn "hot" when the mouse is over them.
    Beside those items, how to react to normal cells? Hotlight the cell text?

  28. #788
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    597

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    The Combo button is already hot-tracked. But yes, the combo cue isn't as it's drawn built in by the grid.
    So, yes. I wouldn't want to have mouse track on by default always for the grid itself.
    Thus having a new "HotTracking" property would be ideal.
    If set to true, all checkboxes and combo cues are being drawn "hot" when the mouse is over them.
    Beside those items, how to react to normal cells? Hotlight the cell text?
    HotTracking: Gets or sets a value determining whether the cell's buttons, column headers, and scroll bar elements indicate hot state.

  29. #789

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Improved AutoSize/FormatString to resize based on best fit rather than text measure only.
    Best fit means to include ComboCue, CheckBox, Picture (NoOverlap align only) and ColSortArrow.
    ColSortArrow was previously included in the internal GetTextSize (CX/CY) function which could be misleading.
    Now included new internal GetBestWidth function and renamed GetTextHeight to GetBestHeight.

    The public exposed functions TextWidth/TextHeight still use the internal GetTextSize function. (but now text only, means without ColSortArrow)

    Included BestFitMode property which defaults to 0 - TextOnly (used for AutoSize/FormatString) to behave like intended.
    Else you can choose between 1 - Full, 2 - SortArrowText or 3 - OtherText.
    Having 2 - SortArrowText is the same as previous behavior, means leaving the other contents (checkbox, combocue) un-measured.
    Last edited by Krool; Dec 30th, 2022 at 04:41 AM.

  30. #790
    New Member
    Join Date
    Nov 2019
    Posts
    2

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    I copy a range from A1 to C3 in excel, then select 3x3 grids in VBflexgrid and click Paste Button (VBFlexgrid1.Paste). data only pasted to second and third column, the second and third row of first column is empty

  31. #791

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by hl88 View Post
    I copy a range from A1 to C3 in excel, then select 3x3 grids in VBflexgrid and click Paste Button (VBFlexgrid1.Paste). data only pasted to second and third column, the second and third row of first column is empty
    Apply following code in Form_Load
    Code:
    VBFlexGrid1.ClipSeparatorRow = vbCrLf

  32. #792

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Quote Originally Posted by DaveDavis View Post
    Can we have an option to have HotTracking, Specifically for Cue button? By doing so, the Cue is lively interaction.
    There is now no new hot-tracking option. It just simply now get's hot-tracked when the MouseTrack property is True.

  33. #793
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    597

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    Update released.



    There is now no new hot-tracking option. It just simply now get's hot-tracked when the MouseTrack property is True.
    very useful, thanks[thumbsup]

  34. #794

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Updated released.

    Support for dynamic checkboxes which are based on the cell text. (added FlexTextAsCheckBox/FlexDisabledTextAsCheckBox enum to FlexCheckBoxConstants)

    Empty text (like DBNull) as grayed state, else text to boolean conversion to either checked or unchecked state.
    The application is responsible to react on CellCheck event to update the cell text to the new state.
    Furthermore the cell text gets hidden/not drawn. Also the label info is as if the cell has no text.

    Currently the text is still measured for those cells which has "hidden text". (e.g. GetTextSize/GetBestHeight/GetBestWidth)
    This may change in future.. though the vsFlexGrid does also still measure. (there is dynamic approach on ColDataType = boolean)

  35. #795

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Included new IVBFlexDataSource2 interface. This additional interface enhances the custom data source. It's not put in stone yet and may be extended. If somebody has further suggestion/ideas please post.

    The new interface must be implemented in addition. It can not work alone.
    Code:
    Option Explicit
    Implements IVBFlexDataSource
    Implements IVBFlexDataSource2
    When IVBFlexDataSource2 is missing then everything is as before.

    Code:
    Private Function IVBFlexDataSource2_GetFlags() As Long
    Provide option flags. Currently these are FlexDataSourceNoFieldNames and FlexDataSourceToolTipText. (Enum FlexDataSourceFlags)
    FlexDataSourceNoFieldNames is convenient because values on fixed rows are not regarded as bound data. So to skip the overwriting via the .GetFieldName just return that flag.
    FlexDataSourceToolTipText allows the tool tip text property to be treated in the flex data source. Otherwise GetToolTipTex/SetToolTipText will not be fired and treated as normal properties.

    Code:
    Private Function IVBFlexDataSource2_GetToolTipText(ByVal Field As Long, ByVal Record As Long) As String
    Called upon TTN_GETDISPINFO or via .CellToolTipText. It allows dynamic tool tip text. E.g. the data source can have a column for tip infos which is hidden but get provided here to another field.

    Code:
    Private Sub IVBFlexDataSource2_SetToolTipText(ByVal Field As Long, ByVal Record As Long, ByVal NewValue As String)
    For completeness the other way around.
    Last edited by Krool; Jan 21st, 2023 at 01:07 PM.

  36. #796

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Added FlexDataSourceUnboundFixedColumns enum to FlexDataSourceFlags.

    With this flag that can be returned by IVBFlexDataSource2::GetFlags the behavior of .FlexDataSource is the same as .DataSource to treat the fixed columns as unbound.
    The reason why .FlexDataSource bounds to the fixed columns was due to compatibility to vsFlexGrid. And of course that keeps this way, this flag just enables a way to change it.

    EDIT:
    Added FlexDataSourceNoData enum.
    This enables to keep the cell texts non-virtual and to make tool tip text virtual only. This allows to take advantage of a certain feature w/o the burden of full fletch virtual source.
    Last edited by Krool; Jan 27th, 2023 at 01:31 PM.

  37. #797
    Lively Member
    Join Date
    May 2022
    Posts
    84

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hi,

    I used the OCX version since now, everything was fine, but i wanted to use the control directly.
    I added all the subs / controls / Res to my project.
    Changed the initial object to Sub Main
    Added the Call SetupVisualStylesFixes(Me) to the main form and the one where it has the VbFlexgrid used.


    Added only 1 VbFlexgrid to a form (the project has more forms), and randomly, when i start (in IDE) my project and load the form (a child form in a MDI project), visual basic closes without error.

    If I just open Vb6 again, load the project and run it, now it works...

    any idea about why this is happening?

    Edit:

    If a compile my project and used it from the exe file, it seems it works fine..

    Then.. i think it has something wrong with Windows 11 + vb6 sp6. I 'll try to find it, but any idea from where to start to look will be great.
    Thanks !

    Edit2:

    I think the RevMditabs control is the problem than me... just if anyone has the same problem, check it first :-(
    Last edited by Calcu; Jan 29th, 2023 at 08:54 AM.

  38. #798
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Dear Krool,

    Greetings! First of all (and as ever), my hearty heartfelt thanks in TONs for your selfless work.

    Well, this message is regarding an issue (as stated below) faced by me while editing inside cells of a ComboEditable column.
    (Note: In case whatever I have stated below as an issue is itself not correct, then, sorry about it. Kindly guide me as to what I should do to have all the navigation keys working while editing inside the cells of a 'ComboEditable' column)

    Issue:
    In a 'ComboEditable' column, when I try to edit inside a cell by pressing F2, 'Up' and 'Down' arrow keys do not act. For instance, at runtime, in UserEditingForm (in the VBFlexGridDemo project provided by you), suppose I press 'F2' in the first cell ("Arnold") under 'ComboEditable' column and press Shift+Enter to create a new line and type "is my name". Now, if I press 'Up' arrow key to move to the top(1st) line "Arnold", it does not act. I need to move the 'Left' arrow key only, to move to the 1st line. Now, if I press 'Down' arrow key to move to the bottom(2nd line), it does not act either. I need to move the 'Right' arrow key only, to move to the 2nd line. 'Home', 'End', etc. navigation keys do not work either.

    Solution tried:
    Initially tried SendKeys and keybd_event, as a quick workaround. They did not act. So, took time to look into the control's code and added an 'if-then-else' line of code at one point. And, it worked. But, I am not sure whether this is the right thing to do. So, I just consider my code alteration (kindly see the red lines below) as a temporary workaround only. I await your correct solution. Thanks.


    Code:
                                If VBFlexGridComboButtonHandle <> 0 And VBFlexGridComboListHandle <> 0 Then
                                  If IsWindowVisible(VBFlexGridComboListHandle) = 0 Then
                                    '
                                  Else
                                    Select Case KeyCode
                                        Case vbKeyUp, vbKeyDown, vbKeyPageDown, vbKeyPageUp, vbKeyHome, vbKeyEnd
                                            SendMessage VBFlexGridComboListHandle, wMsg, wParam, ByVal lParam
                                            Exit Function
                                    End Select
                                  End If
                                End If
    Kind Regards.

  39. #799

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    Dear Krool,

    Greetings! First of all (and as ever), my hearty heartfelt thanks in TONs for your selfless work.

    Well, this message is regarding an issue (as stated below) faced by me while editing inside cells of a ComboEditable column.
    (Note: In case whatever I have stated below as an issue is itself not correct, then, sorry about it. Kindly guide me as to what I should do to have all the navigation keys working while editing inside the cells of a 'ComboEditable' column)

    Issue:
    In a 'ComboEditable' column, when I try to edit inside a cell by pressing F2, 'Up' and 'Down' arrow keys do not act. For instance, at runtime, in UserEditingForm (in the VBFlexGridDemo project provided by you), suppose I press 'F2' in the first cell ("Arnold") under 'ComboEditable' column and press Shift+Enter to create a new line and type "is my name". Now, if I press 'Up' arrow key to move to the top(1st) line "Arnold", it does not act. I need to move the 'Left' arrow key only, to move to the 1st line. Now, if I press 'Down' arrow key to move to the bottom(2nd line), it does not act either. I need to move the 'Right' arrow key only, to move to the 2nd line. 'Home', 'End', etc. navigation keys do not work either.

    Solution tried:
    Initially tried SendKeys and keybd_event, as a quick workaround. They did not act. So, took time to look into the control's code and added an 'if-then-else' line of code at one point. And, it worked. But, I am not sure whether this is the right thing to do. So, I just consider my code alteration (kindly see the red lines below) as a temporary workaround only. I await your correct solution. Thanks.


    Code:
                                If VBFlexGridComboButtonHandle <> 0 And VBFlexGridComboListHandle <> 0 Then
                                  If IsWindowVisible(VBFlexGridComboListHandle) = 0 Then
                                    '
                                  Else
                                    Select Case KeyCode
                                        Case vbKeyUp, vbKeyDown, vbKeyPageDown, vbKeyPageUp, vbKeyHome, vbKeyEnd
                                            SendMessage VBFlexGridComboListHandle, wMsg, wParam, ByVal lParam
                                            Exit Function
                                    End Select
                                  End If
                                End If
    Kind Regards.
    Your suggestion improves the behavior. Thanks! I incorporated this "fix".
    Code:
    If VBFlexGridComboButtonHandle <> 0 And VBFlexGridComboListHandle <> 0 Then
        If IsWindowVisible(VBFlexGridComboListHandle) <> 0 Then
            Select Case KeyCode
                Case vbKeyUp, vbKeyDown, vbKeyPageDown, vbKeyPageUp, vbKeyHome, vbKeyEnd
                    SendMessage VBFlexGridComboListHandle, wMsg, wParam, ByVal lParam
                    Exit Function
            End Select
        End If
    End If
    Last edited by Krool; Feb 2nd, 2023 at 04:47 PM.

  40. #800
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Thanks a lot, Krool, for the prompt update.

    By the way, I noticed one more thing. When I tried to increase the 'RowHeight' (say, in 'EditKeyUp' event - of any editable cell, not necessarily ComboEditable cell) to be in accordance with the 'TextHeight' of the contents of the cell in which I am editing and entering more content, the redrawing of the cell in accordance with the changed row height was not happening. Please see reference screenshot below. The 2nd line ('is my name') is what I have entered extra. The first line ('Arnold') is hiddden above it. These 2 lines are the actual contents of the cell. The 'Arnold' at the bottom you see in the sreenshot is actually not what I typed. This 'Arnold' is the original content (before I added 'is my name') appearing still at the bottom, along with a repeated ComboCue indicator (since the cell's and combocue's redrawing have not taken place, I believe).



    I looked into the control's code and saw a DrawCell method. So, I did try giving .CommitEdit and .StartEdit one after the other whenever I changed the RowHeight but I was not able to place the cursor at the correct editing point again. Please guide me as to how to achieve what I wish for. May be the way I am adopting to change the RowHeight is not the correct way to do it. Kindly help.

    Kind Regards.
    Attached Images Attached Images  
    Last edited by softv; Feb 7th, 2023 at 10:37 PM.

Page 20 of 33 FirstFirst ... 101718192021222330 ... LastLast

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