-
Sep 14th, 2021, 03:36 AM
#601
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Seniorchef
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'.
-
Sep 14th, 2021, 09:03 AM
#602
Member
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
-
Sep 14th, 2021, 09:53 AM
#603
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Seniorchef
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.
-
Sep 14th, 2021, 12:18 PM
#604
Member
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.
Attachment 182323
-
Sep 14th, 2021, 07:19 PM
#605
Member
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
Attachment 182325
-
Sep 15th, 2021, 02:40 AM
#606
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by lizano diaz
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
Attachment 182325
I can't replicate. Please review.
-
Sep 15th, 2021, 06:49 AM
#607
Member
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
-
Sep 15th, 2021, 07:24 AM
#608
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.
-
Sep 15th, 2021, 08:10 AM
#609
Member
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
-
Sep 15th, 2021, 09:18 AM
#610
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Seniorchef
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..
-
Sep 15th, 2021, 11:46 AM
#611
Member
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
-
Sep 15th, 2021, 11:54 AM
#612
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
-
Sep 15th, 2021, 12:19 PM
#613
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Arnoutdv
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.
-
Sep 15th, 2021, 12:24 PM
#614
Member
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
-
Sep 15th, 2021, 12:32 PM
#615
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Seniorchef
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.
-
Sep 15th, 2021, 12:51 PM
#616
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?
-
Sep 15th, 2021, 01:07 PM
#617
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Arnoutdv
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.
-
Sep 15th, 2021, 03:23 PM
#618
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Maybe an additional event CompareValues and an additional sort method, CustomValue
-
Sep 15th, 2021, 09:49 PM
#619
Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Please krool could you support me with the request of: # 604
Please thank you very much
-
Sep 16th, 2021, 01:22 AM
#620
Member
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
-
Sep 16th, 2021, 02:53 AM
#621
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
-
Sep 16th, 2021, 04:03 AM
#622
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..
-
Sep 16th, 2021, 04:37 AM
#623
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
*Text instead of *Value is indeed better, much more obvious what is going on.
-
Sep 16th, 2021, 05:37 AM
#624
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..
-
Sep 18th, 2021, 08:38 AM
#625
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Originally Posted by Arnoutdv
*Text instead of *Value is indeed better, much more obvious what is going on.
Included the FlexSortCustomText enum with corresponding CompareText event.
-
Sep 20th, 2021, 08:24 AM
#626
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I found a way to "improve" the bubble sort.
Let's take the demo example (rows increased from 150 to 600)
The original version takes 11 seconds in the IDE. The new modified version takes 3.5 seconds.
The green part is old and commented out. The blue part is added.
The red part is the time safer. The ReDim needs to be done only 1 time.
Code:
Private Sub BubbleSortIter(ByVal First As Long, ByVal Last As Long, ByVal Col As Long, ByRef Data() As TCOLS)
Dim Swap As TCOLS, Cmp As Long
ReDim Swap.Cols(0 To (PropCols - 1)) As TCELL
Dim i As Long, j As Long, iCol As Long
Do While Last > First
i = First
For j = First To Last - 1
Cmp = 0
RaiseEvent Compare(j, j + 1, Col, Cmp)
If Cmp > 0 Then
' LSet Swap = Data(j + 1)
' LSet Data(j + 1) = Data(j)
' LSet Data(j) = Swap
LSet Swap.RowInfo = Data(j + 1).RowInfo
LSet Data(j + 1).RowInfo = Data(j).RowInfo
LSet Data(j).RowInfo = Swap.RowInfo
For iCol = 0 To (PropCols - 1)
LSet Swap.Cols(iCol) = Data(j + 1).Cols(iCol)
LSet Data(j + 1).Cols(iCol) = Data(j).Cols(iCol)
LSet Data(j).Cols(iCol) = Swap.Cols(iCol)
Next iCol
i = j
End If
Next j
Last = i
Loop
End Sub
What you think ?
EDIT: (revised version, to be released soon)
Code:
Private Sub BubbleSortIter(ByVal First As Long, ByVal Last As Long, ByVal Col As Long, ByRef Data() As TCOLS)
Dim SwapRowInfo As TROWINFO, SwapCell As TCELL, Cmp As Long
Dim i As Long, j As Long, iCol As Long
Do While Last > First
i = First
For j = First To Last - 1
Cmp = 0
RaiseEvent Compare(j, j + 1, Col, Cmp)
If Cmp > 0 Then
LSet SwapRowInfo = Data(j + 1).RowInfo
LSet Data(j + 1).RowInfo = Data(j).RowInfo
LSet Data(j).RowInfo = SwapRowInfo
For iCol = 0 To (PropCols - 1)
LSet SwapCell = Data(j + 1).Cols(iCol)
LSet Data(j + 1).Cols(iCol) = Data(j).Cols(iCol)
LSet Data(j).Cols(iCol) = SwapCell
Next iCol
i = j
End If
Next j
Last = i
Loop
End Sub
Code:
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)
Dim Temp() As TCOLS, Cmp As Long, Dst As Long
Dim i As Long, j As Long, iCol As Long
Dim Dbl1 As Double, Dbl2 As Double
ReDim Temp(Middle - Left) As TCOLS
j = 0
For i = Left To Middle
LSet Temp(j) = Data(i)
j = j + 1
Next i
j = 0
Dst = Left
Do While i <= Right And j <= UBound(Temp)
Cmp = 0
Select Case Sort
Case FlexSortGenericAscending, FlexSortGenericDescending
If Not IsNumeric(Data(i).Cols(Col).Text) Or Not IsNumeric(Temp(j).Cols(Col).Text) Then
If Data(i).Cols(Col).Text < Temp(j).Cols(Col).Text Then
Cmp = -1
ElseIf Data(i).Cols(Col).Text > Temp(j).Cols(Col).Text Then
Cmp = 1
End If
Else
Dbl1 = Empty: Dbl2 = Empty
On Error Resume Next
Dbl1 = CDbl(Data(i).Cols(Col).Text)
Dbl2 = CDbl(Temp(j).Cols(Col).Text)
On Error GoTo 0
Cmp = Sgn(Dbl1 - Dbl2)
End If
If Sort = FlexSortGenericDescending Then Cmp = -Cmp
Case FlexSortNumericAscending, FlexSortNumericDescending
Dbl1 = Empty: Dbl2 = Empty
On Error Resume Next
Dbl1 = CDbl(Data(i).Cols(Col).Text)
Dbl2 = CDbl(Temp(j).Cols(Col).Text)
On Error GoTo 0
Cmp = Sgn(Dbl1 - Dbl2)
If Sort = FlexSortNumericDescending Then Cmp = -Cmp
Case FlexSortStringNoCaseAscending, FlexSortStringNoCaseDescending
Cmp = lstrcmpi(StrPtr(Data(i).Cols(Col).Text), StrPtr(Temp(j).Cols(Col).Text))
If Sort = FlexSortStringNoCaseDescending Then Cmp = -Cmp
Case FlexSortStringAscending, FlexSortStringDescending
Cmp = lstrcmp(StrPtr(Data(i).Cols(Col).Text), StrPtr(Temp(j).Cols(Col).Text))
If Sort = FlexSortStringDescending Then Cmp = -Cmp
Case FlexSortCurrencyAscending, FlexSortCurrencyDescending
Dim Cur1 As Currency, Cur2 As Currency
Cur1 = Empty: Cur2 = Empty
On Error Resume Next
Cur1 = CCur(Data(i).Cols(Col).Text)
Cur2 = CCur(Temp(j).Cols(Col).Text)
On Error GoTo 0
Cmp = Sgn(Cur1 - Cur2)
If Sort = FlexSortCurrencyDescending Then Cmp = -Cmp
Case FlexSortDateAscending, FlexSortDateDescending
Dim Date1 As Date, Date2 As Date
Date1 = Empty: Date2 = Empty
On Error Resume Next
Date1 = CDate(Data(i).Cols(Col).Text)
Date2 = CDate(Temp(j).Cols(Col).Text)
On Error GoTo 0
Cmp = Sgn(Date1 - Date2)
If Sort = FlexSortDateDescending Then Cmp = -Cmp
Case FlexSortCustomText
RaiseEvent CompareText(Data(i).Cols(Col).Text, Temp(j).Cols(Col).Text, Col, Cmp)
End Select
If Cmp < 0 Then
LSet Data(Dst).RowInfo = Data(i).RowInfo
For iCol = 0 To (PropCols - 1)
LSet Data(Dst).Cols(iCol) = Data(i).Cols(iCol)
Next iCol
i = i + 1
Else
LSet Data(Dst).RowInfo = Temp(j).RowInfo
For iCol = 0 To (PropCols - 1)
LSet Data(Dst).Cols(iCol) = Temp(j).Cols(iCol)
Next iCol
j = j + 1
End If
Dst = Dst + 1
Loop
Do While j <= UBound(Temp)
LSet Data(Dst).RowInfo = Temp(j).RowInfo
For iCol = 0 To (PropCols - 1)
LSet Data(Dst).Cols(iCol) = Temp(j).Cols(iCol)
Next iCol
Dst = Dst + 1
j = j + 1
Loop
End Sub
Last edited by Krool; Sep 22nd, 2021 at 02:05 AM.
-
Sep 22nd, 2021, 11:50 AM
#627
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Updated BubbleSortIter/InplaceMergeSort for better performance on UDT assignment.
-
Sep 24th, 2021, 12:54 PM
#628
New Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Also posted in the [VB6] variant thread (just saw this one):
Does this work in Excel? Does anyone have an example of how to get this up and running in an Excel form?
I added a reference to the ocx and tlb but cannot see a control to add to the palette in the form builder. What are the steps please?
Thank you!
-
Sep 29th, 2021, 11:32 AM
#629
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Question..
For a potential .ColSortArrow property should I use a fixed image for up/down arrow or just draw with same cell font as unicode char U+25B2 (▲) and U+25BC (▼) ?
-
Sep 29th, 2021, 01:45 PM
#630
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
Question..
For a potential .ColSortArrow property should I use a fixed image for up/down arrow or just draw with same cell font as unicode char U+25B2 (▲) and U+25BC (▼) ?
How about using the Unicode characters unless they are not present in whatever font you are using in which case you switch to a fixed image?
-
Sep 30th, 2021, 11:43 AM
#631
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by MountainMan
How about using the Unicode characters unless they are not present in whatever font you are using in which case you switch to a fixed image?
Using Unicode character is easier at it scales according to size/dpi etc.
So unless a Wingdings font is used this works great. And it works back to Win XP, no? (Need to test)
Also the fore color works in sync
-
Oct 1st, 2021, 03:41 PM
#632
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Included the ColSortArrow property. I decided to just draw a triangle to be independent of fonts. Also it ensures to work then in Windows XP.
However, the triangle is calculated upon TEXTMETRICS so it scales accordingly..
The internal GetTextSize and GetLabelInfo considers the triangle accordingly.
The triangle is only drawn on the first fixed row.
This code will conveniently remove (quickly) all sort arrows on each column.
Code:
VBFlexGrid1.ColSortArrow(-1) = FlexSortArrowNone
Last edited by Krool; Oct 5th, 2021 at 02:08 PM.
-
Oct 2nd, 2021, 05:22 AM
#633
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Currently the sort arrow is drawn right or left aligned depending on the text alignment. When text is left or centered the sort arrow is right, else left.
I may include another ColSortArrowAlignment property which could be set to 0 - NoControl, 1 - Right and 2 - Left...
-
Oct 3rd, 2021, 03:34 AM
#634
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Included the ColSortArrowColor property.
The default value on each column is -1. This means the applied text color of that cell is used as color for the sort arrow.
This property allows to specify an explicit color.
-
Oct 4th, 2021, 02:13 AM
#635
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Some finetuning for ColSortArrowColor property.
When set to -1 the get property will not return -1 anymore and just fallback to the color that will be used then for drawing.
This is then in line with the other color properties and the fallbacks accordingly.
-
Oct 4th, 2021, 07:54 AM
#636
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Renamed enum FlexColSortArrowUp to FlexColSortArrowAscending and FlexColSortArrowDown to FlexColSortArrowDescending.
This is then easier to use (not to think about if up is ascending and down is descending) and also in harmony with the general sort enums.
Included the RowSortArrows property. The default value is 0 for the first fixed row. This property may be modified to display the sort arrows on a different fixed row.
-
Oct 4th, 2021, 12:22 PM
#637
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Introduced now a SortArrowColor property which defaults to vbGrayText.
It's in practise easier to have a global color property which can be set at design time. Because ColSortArrowColor needs to be set by code and when a grid erases (e.g. Rows = 0) the values are lost.
So, ColSortArrowColor still exists now and when set to -1 it fallbacks to the global SortArrowColor.
This is much cleaner and more predictable than the previous two cases fallback between cell forecolor and forecolor fixed.
-
Oct 8th, 2021, 01:04 PM
#638
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear krool,
As always, my thanks in TONS to you for your free contribution to this world society. And, special thanks for the sort arrow with color, default color, alignment, etc. I was using my own simple arrow earlier. Your work with so many options makes it all so easy now. I have not explored them fully yet. Will do soon but lot many thanks in advance.
Well, is there a page which explains the meaning of all (or the most important) properties of your VBFlexGrid control? For instance, intuitively, I thought .colsvisible will just give me the number of columns which are not hidden in a grid (i.e. total number of columns minus the columns with .colhidden = true) but it was not so. Object browser told me that .colsvisible "Returns the total number of columns or rows visible in the flex grid."
To understand the above statement from the Object Browser better, I just experimented with a sample 10*10 flex grid. I realised that even if I hide some columns (say 1, 2 and 3) and reduce the width of the grid to show only 2 columns (i.e. only column 0 and column 4), then also .colsvisible will return 5 and not 2. Is it so by design? Just a clarification. Thats all.
.rowsvisible also behaves similarly with a similar experiment as above. So, just wanted to clarify whether .colsvisible and .rowsvisible are designed to report values in the above manner only.
I have some clarifications regarding how and where to avail ComboListCount, ComboListIndex, ComboList, etc. Will ask them in a separate message.
Thanks again.
Kind regards.
-
Oct 9th, 2021, 01:53 AM
#639
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear krool,
This is in continuation of my last message (in which I have requested your clarification on .colsvisible and .rowsvisible).
And, reg. the various ComboList values, I am sorry that I am not that very clear in my understanding of them.
So, via the following cases, I am trying to understand them in the right way from you. So, kindly please help.
Case 1)
In your VBFlexGrid demo, in UserEditingForm, I have the following lines at the end of the Form_Load event.
Code:
Debug.Print VBFlexGrid1.ComboListCount
Debug.Print VBFlexGrid1.ComboListIndex
Debug.Print VBFlexGrid1.ComboList(10) & "Z"
Debug.Print VBFlexGrid1.ColComboItems(10)
The above print '0', '0', 'Z' and 'Arnold|Bob|Charlie|David|Elena|Felix|Greg|Hanna|Ivan|Jacob'
a) Why '0' got printed for .ComboListCount? Why .ComboList(10) prints empty string?
b) Even if I make the rows count as 2 for VBFlexGrid1 and select 'Ivan' (instead of the default Arnold) in both the 10th and 11th columns, then also .ComboListIndex is printed as '0' only. Why?
c) Perhaps .ComboList, .ComboListCount and .ComboListIndex carry meaning only when they are used in specific events like VBFlexGrid1_EnterEdit(), VBFlexGrid1_LeaveEdit(), etc.? If so, in which all events they carry meaning? Please let me know.
Case 2)
At the end of the VBFlexGrid1_EnterEdit() event, I have the following lines.
Code:
Debug.Print VBFlexGrid1.ComboListCount
Debug.Print VBFlexGrid1.ComboListIndex
'''''Debug.Print VBFlexGrid1.ComboList(10) & "Z"
Debug.Print VBFlexGrid1.ColComboItems(10)
And, when I double click a cell in the 10th column where 'Charlie' is present, what get printed are:
'10', '2' and 'Arnold|Bob|Charlie|David|Elena|Felix|Greg|Hanna|Ivan|Jacob'
I had to comment out the 3rd line above because it caused a run time error (Invalid procedure call or argument).
a) Why the 3rd line caused an error? Please educate me. Is it that it cannot or should not be used in certain events?
b) Where then should (or where all I can) use that line so that it will show some output?
c) What actually is .ComboList(10) supposed to show? Is it supposed to show the same output of ColComboItems(10) but without the '|' and all the 10 names displayed one after the other, in 10 lines?
Case 3)
At the end of the VBFlexGrid1_LeaveEdit() event, I have the following lines.
Code:
Debug.Print VBFlexGrid1.ComboListCount
Debug.Print VBFlexGrid1.ComboListIndex
'Debug.Print VBFlexGrid1.ComboList(10) & "A"
Debug.Print VBFlexGrid1.ColComboItems(10)
VBFlexGrid1.ComboListIndex = 9
Debug.Print "yes"; VBFlexGrid1.ComboListIndex
And, when I double click a cell in the 10th column where Charlie is present and select Charlie itself again, what get printed are:
'10', '2', 'Arnold|Bob|Charlie|David|Elena|Felix|Greg|Hanna|Ivan|Jacob' and 'yes 9'
a) I had to keep the 3rd line commented out here also since it caused the same run time error (Invalid procedure call or argument).
b) Though I changed the .ComboListIndex to 9, the selection remained at 'Charlie' only.
c) So, where and how should I use .ComboListIndex so that I can "programmatically" change/select the ComboList item in any cell in the 10th column (ComboDropDown) without having to manually double click a cell and select a particular item in the list.
Thanks a TON once again for your contribution to the world society.
Kind regards.
Last edited by softv; Oct 9th, 2021 at 02:10 AM.
-
Oct 9th, 2021, 02:08 AM
#640
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear krool,
One more thing. Can there be a 'ExtendThisCol = <Col No.>' property too?
For instance, say my design requires me to have a chunk of text in the 1st column of a 3-column grid and fixed width values in the 2 and 3rd columns.
Then, I would not like to extend my last column. I would like to extend my first column only. So, in such cases, 'ExtendThisCol' property will be very helpful I thought. Of course, I can do this via code itself. In fact, I was already achieving 'EntendLastCol' through my own code only. But, a properly like 'EntendLastCol' introduced by you is easier and thus very helpful. That's why my suggestion for ExtendThisCol too.
Kind regards.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|