Page 16 of 16 FirstFirst ... 613141516
Results 601 to 624 of 624

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

  1. #601

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Seniorchef View Post
    Ok - I'll try it in words.

    I am quite sure the grid supports multicolumn sort. Here the columns to sort are not simply from left to right nor beneath each other.
    E.g. a grid with 5 columns 'City' 'Name' 'Firstname' 'Street' 'Record' are to be sorted like a phonebook. That is 'City', 'Name', 'Firstname' - no matter what column number 'City' or 'Name' etc. are. I've seen the properties Grid.ColSort and Grid.ColData, but I guess I need a way to tell the sorting routine the order 'City' - 'Name' - 'Firstname' or better, the indices of the columns, not the range like Grid.Col and Grid.ColSel.

    Greetings
    Seniorchef
    If the columns are not "range-able" (Col to ColSel) then you might to sort manually each column.
    If you want to sort by order of 'City' 'Name' 'Firstname' 'Street' 'Record' then you sort in reverse order to achieve "multi-column" sort.

    So first sort by 'Record', then by 'Street' and so on until 'City'.

  2. #602
    New Member
    Join Date
    Mar 2020
    Posts
    9

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Thank you, Krool - I'll give it a try.
    With the msHFlexGrid I sort with flexSortCustom and the compare event, but unfortunately the VBFlexgrid is very slow in using this method.
    Regards
    Seniorchef

  3. #603

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Seniorchef View Post
    Thank you, Krool - I'll give it a try.
    With the msHFlexGrid I sort with flexSortCustom and the compare event, but unfortunately the VBFlexgrid is very slow in using this method.
    Regards
    Seniorchef
    Yes..

    MergeSort is used for automatic sorting as it is fast and stable.

    BubbleSort is used for custom sorting as row1/row2 for text matrix must be meaningful in the 'Compare' event.

    If a faster replacement for the custom sorting is possible I am eager to read about.

  4. #604
    Member
    Join Date
    Apr 2021
    Posts
    39

    Red face Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hello friend Krool, how can I do? to be able to have cells with progressBar in the VbFlexgrid.
    Please I need your support.

    Name:  ProgresBar.jpg
Views: 70
Size:  58.9 KB

  5. #605
    Member
    Join Date
    Apr 2021
    Posts
    39

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

    Dear Krool I found a problem in the grid, this happens when you add the grid in a form, and you put it in properties:
    FixedRos = 1
    rows = 2
    fixedcol = 0

    You close the form and open the form again and Vb 6.0 hangs (does not respond).

    attached image

    Name:  Error Grid.jpg
Views: 66
Size:  20.5 KB

  6. #606

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by lizano diaz View Post
    Dear Krool I found a problem in the grid, this happens when you add the grid in a form, and you put it in properties:
    FixedRos = 1
    rows = 2
    fixedcol = 0

    You close the form and open the form again and Vb 6.0 hangs (does not respond).

    attached image

    Name:  Error Grid.jpg
Views: 66
Size:  20.5 KB
    I can't replicate. Please review.

  7. #607
    New Member
    Join Date
    Mar 2020
    Posts
    9

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hello, Krool!
    Sorry for my late answer, but I wanted to test the issue before I report.
    I don't know how, but the custom sort of the msHFlexgrid is way faster than the custom sort of the vbFlexGrid - it's about the factor 30 on a single column sort. So they have either a different way to sort customly or a faster algorithm.
    Just a thought. I would love to replace the msHFlexGrid with the VBFlexGrid, but the custom sort is a real killjoy.
    Thanks for your efforts anyway. I really appreciate your work very well.
    Regards
    Seniorchef

  8. #608
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,674

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    How many records are you talking about?

    How do you initially fill the grid?
    If it's from a query then you could add sorting to the query.
    If it's from some other dataset then you could do a sort on your data first, before assigning it to the grid.

  9. #609
    New Member
    Join Date
    Mar 2020
    Posts
    9

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hello, Arnoutdv!
    In this test it's 600 records - it becomes worse with more records (obviously).
    On my pc it took 6 sec with vbFlexGrid and 0.2 sec with msHFlexgrid.
    The grid is filled already, and I sort per mouseclick on columnheader. The data is unbound.
    Greetings
    Seniorchef

  10. #610

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Seniorchef View Post
    Hello, Arnoutdv!
    In this test it's 600 records - it becomes worse with more records (obviously).
    On my pc it took 6 sec with vbFlexGrid and 0.2 sec with msHFlexgrid.
    The grid is filled already, and I sort per mouseclick on columnheader. The data is unbound.
    Greetings
    Seniorchef
    6 sec with 600 records?
    Can you share the code? (Maybe there is a late-bound inefficiency)

    Also, what kind of custom sort you are doing?
    For instance VbFlexGrid has an enum for date sort (thus fast as not custom) maybe I can add an enum for your use-case.

    I also check if I can change the BubbleSort to a GnomeSort for custom sorting. (It should perform a little bit better) Lets see..

  11. #611
    New Member
    Join Date
    Mar 2020
    Posts
    9

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hello, Krool!
    I know - 6 seconds is a long time compared to 0.2 seconds.
    Even if it is a slow pc and there is a lot of overhead while sorting, this is valid for both grids. The code I use to test is identical (except the compare-event for each grid has one different argument).

    I'm doing the custom sort to achive multicolumn sort, ascending, descending in flexible order (see my post #601).
    I know about the built-in sort abilities, but they cannot sort as flexible as I need to. On the other hand, the custom sort works really fine and is exactly what I need, but it is slow.

    It is the BubbleSortIter() Sub. I'm not experienced in sorting algorithms, but maybe it should be replaced by a faster one.
    If we knew the way the msHflexGrid handles this we had the solution, I'm sure.
    Maybe there is a user who can tell us.

    Greetings
    Seniorchef

  12. #612
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,674

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Bubblesort is stable, but very slow, sorting method
    Mergesort is also stable and much faster.

    @Seniorchef, have you tried it compiled or only from within the IDE?

    Mergesort implementation:
    http://www.vb-helper.com/howto_mergesort.html

  13. #613

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Arnoutdv View Post
    Bubblesort is stable, but very slow, sorting method
    Mergesort is also stable and much faster.
    I use MergeSort already.

    However, for custom sort (firing Compare event where Text Matrix of row1/row2 are valid) the Merge Sort is not possible, thus BubbleSort for that.

    If there is a working/valid alternative possible please let me know.

  14. #614
    New Member
    Join Date
    Mar 2020
    Posts
    9

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hello, Arnoutdv!
    Honestly, I tested it in the IDE. But after your post I compiled it and - the result stays the same.
    Btw, thank you for the link - MergeSort is already in the VBFlexGrid Sort routine, and, if possible and his time permits, it should be adapted by Krool for the custom sort.
    Either way, I don't want to rush the issue, and maybe he'll find another way to speed up the routine.
    Regards
    Seniorchef

  15. #615

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Seniorchef View Post
    Hello, Arnoutdv!
    Honestly, I tested it in the IDE. But after your post I compiled it and - the result stays the same.
    Btw, thank you for the link - MergeSort is already in the VBFlexGrid Sort routine, and, if possible and his time permits, it should be adapted by Krool for the custom sort.
    Either way, I don't want to rush the issue, and maybe he'll find another way to speed up the routine.
    Regards
    Seniorchef
    Again, it's logical NOT POSSIBLE to use merge sort for custom sort.

  16. #616
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,674

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    And that's because you can not just pass the 2 values to compare, but because the sorted items can also be things like the backcolor of the cell or it's custom data property?

  17. #617

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Arnoutdv View Post
    And that's because you can not just pass the 2 values to compare, but because the sorted items can also be things like the backcolor of the cell or it's custom data property?
    Well yes... The MS(H)FlexGrid also passes row1/row2.
    If I would pass Text1/Text2 to Compare event the MergeSort would work.

  18. #618
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,674

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Maybe an additional event CompareValues and an additional sort method, CustomValue

  19. #619
    Member
    Join Date
    Apr 2021
    Posts
    39

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Please krool could you support me with the request of: # 604

    Please thank you very much

  20. #620
    New Member
    Join Date
    Mar 2020
    Posts
    9

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hello and good morning.
    Ok, this morning I woke up and I think I got a solution for my problem. If it works, there will be no need for the custom sort event cause I'll enhance the regular sort routine. I'll try it and tell the results.
    Greetings
    Seniorchef

  21. #621
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,674

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    I tested the following:
    Code:
    ' VBFlexGrid.ctl
    
    Private FlexSortNone, FlexSortGenericAscending, FlexSortGenericDescending, FlexSortNumericAscending, FlexSortNumericDescending, FlexSortStringNoCaseAscending, FlexSortStringNoCaseDescending, FlexSortStringAscending, FlexSortStringDescending, FlexSortCustom, FlexSortCustomValue, FlexSortUseColSort, FlexSortCurrencyAscending, FlexSortCurrencyDescending, FlexSortDateAscending, FlexSortDateDescending
    
    Public Enum FlexSortConstants
    FlexSortNone = 0
    FlexSortGenericAscending = 1
    FlexSortGenericDescending = 2
    FlexSortNumericAscending = 3
    FlexSortNumericDescending = 4
    FlexSortStringNoCaseAscending = 5
    FlexSortStringNoCaseDescending = 6
    FlexSortStringAscending = 7
    FlexSortStringDescending = 8
    FlexSortCustom = 9
    FlexSortUseColSort = 10
    FlexSortCurrencyAscending = 11
    FlexSortCurrencyDescending = 12
    FlexSortDateAscending = 13
    FlexSortDateDescending = 14
    FlexSortCustomValue = 15
    End Enum
    
    Public Event CompareValue(Value1 As String, Value2 As String, ByRef Cmp As Long)
    
    Private Sub InplaceMergeSort(ByVal Left As Long, ByVal Middle As Long, ByVal Right As Long, ByVal Col As Long, ByRef Data() As TCOLS, ByVal Sort As FlexSortConstants)
    '
    ' 
        Select Case Sort
            Case FlexSortCustomValue
              RaiseEvent CompareValue(Data(i).Cols(Col).Text, Temp(j).Cols(Col).Text, Cmp)
    Code:
    ' MainForm
    Private Sub VBFlexGrid1_Compare(ByVal Row1 As Long, ByVal Row2 As Long, ByVal Col As Long, Cmp As Long)
      Dim dValue1 As Double, dValue2 As Double
      dValue1 = CDbl(VBFlexGrid1.TextMatrix(Row1, Col))
      dValue2 = CDbl(VBFlexGrid1.TextMatrix(Row2, Col))
      If dValue1 > dValue2 Then Cmp = 1 Else Cmp = -1
    End Sub
    
    Private Sub VBFlexGrid1_CompareValue(Value1 As String, Value2 As String, Cmp As Long)
      If CDbl(Value1) > CDbl(Value2) Then Cmp = 1 Else Cmp = -1
    End Sub
    
    
    Private Sub Command17_Click()
    Dim Row1 As Long, Row2 As Long
    Dim Col1 As Long, Col2 As Long
    With VBFlexGrid1
    .GetSelRange Row1, Col1, Row2, Col2
    .RowID(.Row) = 1 ' Temporary identification
    .Sort = FlexSortCustomValue
    '.Sort = VBA.Choose(Combo2.ListIndex + 1, FlexSortGenericAscending, FlexSortNumericAscending, FlexSortStringNoCaseAscending, FlexSortStringAscending, FlexSortCurrencyAscending, FlexSortDateAscending)
    .Row = .RowIndex(1)
    .RowID(.RowIndex(1)) = 0 ' Remove temporary identification
    .CellEnsureVisible
    If Row1 <> Row2 Then .RowSel = IIf(Row1 < .Row, Row1, Row2)
    If Col1 <> Col2 Then .ColSel = IIf(Col1 < .Col, Col1, Col2)
    End With
    End Sub
    It's running in full speed on the sample VBFlexGridDemo with 600 rows
    I first sort Column 1 with the Dates Descending with SortType "String"
    Then a numeric value column with Sort Asc, which has a hardcoded .Sort = FlexSortCustumValue

  22. #622

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    @ Arnoutdv,

    good idea with a second custom sort which can be based on the merge sort.

    However, why CustomValue/CompareValue (Value1/Value2) ? I would like CustomText/CompareText (Text1/Text2) more..

  23. #623
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,674

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    *Text instead of *Value is indeed better, much more obvious what is going on.

  24. #624

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,846

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Even VSflexGrid admits that it's of magnitude slower the Compare event.
    http://helpcentral.componentone.com/...mpareevent.htm
    So I'm wondering what the heck msHFlexGrid is doing..

Page 16 of 16 FirstFirst ... 613141516

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