-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
immortalx
Krool I noticed that properties RowIsVisible, ColIsVisible return always true, no matter if the respective Row or Col are hidden or not.
Or maybe I'm doing something wrong?
VBFlexGrid1.RowHidden(0) = True is just an "extended" way of VBFlexGrid1.RowHeight(0) = 0.
Thus like in original MSFlexGrid those zero height rows will still be return True by RowIsVisible if the row is within client rect, even if it's height is zero.
Even in the VSFlexGrid control it says: If a row has zero height or is hidden but is within the scrollable area, RowIsVisible will return True.
So I won't change the behavior in order to be full compatible.
However, you can make your own workaround helper function as following:
Code:
Public Function FlexGridRowIsVisible(ByRef FlexGrid As VBFlexGrid, ByVal Row As Long) As Boolean
If FlexGrid.RowIsVisible(Row) = True And FlexGrid.RowHidden(Row) = False Then FlexGridRowIsVisible = True
End Function
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thank you very much for the explanation Krool. I didn't know that was the case for MSFlexGrid too and certainly I'd never ask you to change this behavior! I was just curious as a beginner and the original property names RowIsVisible/RowHidden were a bit misleading to me :D
Also thank you for the helper function and for all your contributions to this community. Much appreciated!
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Good work, Krool.
There is a VerticalAlignment, for Text cell (Top, Middle, Bottom) ?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
gibra
There is a VerticalAlignment, for Text cell (Top, Middle, Bottom) ?
The .CellAlignment is used for both, horizontal and vertical text alignment.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
The .CellAlignment is used for both, horizontal and vertical text alignment.
Now I have found it, and it's very simple to use. :cool:
Great!!!
It would also be nice to have a FilterBar (like the ComponentOne TrueDBGrid control).
Have you ever thought about implementing it?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
The FlexSortCustom was totally broken. This fact appeared when I needed in a case a custom sorting and I noticed that Row1 in the Compare event was correct but Row2 was totally off.
Row2 had two errors, one could be fixed but the other is kind of impossible due to the partial temp out-of-place sorting in the recursive stable merge sort.
So now, whenever a custom sort is invoked an optimized stable bubble sort is performed internally. This ensure that the Row1/Row2/Col text matrix subscripts is meaningful and properly. Because bubble sort is full in-place and is swapping one by one. So .TextMatrix is always up to date. So no problem for the Compare event anymore.
If no custom sort is applied, then the fast and efficient stable merge sort is again internally used.
In order to decrease the need of custom sorting I have included now the possibility to sort by currency and date. (FlexCurrencyAscending/FlexCurrencyDescending and FlexDateAscending/FlexDateDescending)
These new enum flag can be set to both Sort and ColSort property. (Info: In order to use ColSort set FlexUseColSort enum into the Sort property)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Most stupid bugfix ever... related to yesterday bugfix and new bubble sort for custom sorting.
In the internal method BubbleSortIter it should be
and not
Now, equal items (Cmp = 0) won't be sorted. (which is wanted)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
DividerDblClick event included.
This convenient event can be a very quick helper for implementing an "user auto auto-sizing" functionality.
Example usage:
Code:
Private Sub VBFlexGrid1_DividerDblClick(ByVal Row As Long, ByVal Col As Long)
If Row = -1 Then
VBFlexGrid1.AutoSize Col, , FlexAutoSizeModeColWidth
ElseIf Col = -1 Then
VBFlexGrid1.AutoSize Row, , FlexAutoSizeModeRowHeight
End If
End Sub
Like in the ListView control it only fires on left mouse button.
-
1 Attachment(s)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Updated released.
Optimized the divider row/col dragging.
This means that now the splitter rect displayed during the divider row/col dragging starts not anymore at the current mouse position.
It now starts exactly at the divider line and calculates internally an offset to the current mouse position.
Of course when moving and releasing the mouse the offset is also considered.
The benefit of this optimization is a more precise dragging and no mini pixel movings anymore when pressing and releasing the mouse without moving.
Attachment 157241
Included the HitRowDivider/HitColDivider property which returns the divider row/col from the last invoked .HitTest.
The difference between HitRowDivider/HitColDivider and the normal HitRow/HitCol is an offset applied.
Also either HitRowDivider and HitColDivider is set to -1 or both. Never both can be higher than -1. Unlike HitRow/HitCol where both are usually higher than -1.
The offset accounts following:
Normally for FlexHitResultDividerRowTop/FlexHitResultDividerColumnLeft an offset of -1 must be applied to shift to the actual row/col.
For FlexHitResultDividerRowBottom/FlexHitResultDividerColumnRight an offset was never necessary.
In addition (new feature) the offset also accounts for hidden rows and cols. Though zero width rows/cols are not accounted to preserve MSFlexGrid compatibility.
Example: In MSFlexGrid a zero width row/col can be resized (unhide). This is also possible in VBFlexGrid.
Only when using ColHidden/RowHidden the hidden rows/cols cannot be resized anymore as they were offset.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Quote:
Originally Posted by
Krool
FontCharset issue resolved. Whenever the FontName is changed the FontCharset will be amended as well by default. Thus always working.
However, afterwards the FontCharset can be changed manually, if necessary.
Now that fix applies also for FlexFillStyleRepeat instead of FlexFillStyleSingle only. (FlexFillStyleRepeat was skip by an oversight..)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I find the .Clip property useful for copy/paste between grid and excel for example.
I also use RowHidden/ColHidden often to filter stuff out of sight.
Therefore the question in the room:
May the .Clip property skip hidden rows/cols by get and also set? (Kind of intuitive feature)
Or bring out a further property that controls such new behavior?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
I find the .Clip property useful for copy/paste between grid and excel for example.
I also use RowHidden/ColHidden often to filter stuff out of sight.
Therefore the question in the room:
May the .Clip property skip hidden rows/cols by get and also set? (Kind of intuitive feature)
Or bring out a further property that controls such new behavior?
I vote for a new property. While the intuitive behavior works from an end user point of view (this is how excel works), it may not be obvious to a programmer. :)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Who has the VBFlexGrid drag and drop example? How can I not use the following example?
Private m_bDragOK As Boolean
Private m_iDragCol As Integer
Private xdn As Integer, ydn As Integer
Private Sub VBFlexGrid1_DragDrop(Source As Control, X As Single, Y As Single)
If m_iDragCol = -1 Then Exit Sub
If VBFlexGrid1.MouseRow <> 0 Then Exit Sub
With VBFlexGrid1
.Redraw = False
.ColPosition(m_iDragCol) = .MouseCol
.Redraw = True
End With
End Sub
Private Sub VBFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xdn = X
ydn = Y
m_iDragCol = -1 ' 清除拖拽标志
m_bDragOK = True
End Sub
Private Sub VBFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
m_bDragOK = False
End Sub
-
1 Attachment(s)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I uploaded an example that can be dragged but cannot adjust the column width. This example is normal when using MSHFLEXGRID.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Quote:
Originally Posted by
ChenLin
I uploaded an example that can be dragged but cannot adjust the column width. This example is normal when using MSHFLEXGRID.
This is now fixed. Thanks for bringing this up!
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thank you Krool. The problem is solved. I hope this drag and drop attribute is the default, and no user need to write the code again. That's the best thing to do.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
DEXWERX
I vote for a new property. While the intuitive behavior works from an end user point of view (this is how excel works), it may not be obvious to a programmer. :)
Update, included ClipMode property that determines whether to include (default) or to exclude hidden cells in a clip command.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Further question in the room:
The AutoSize feature does not currently allow to exclude hidden rows or cols in it's calculation.
This can be disturbing in a filtered grid and you double click on a divider to autosize and it sizes larger as it should be visibly due to hidden cells that are larger in it's content.
So bring out a new parameter for this or rely on what is set in the new ClipMode property? (Kind of half intiutive)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi Krool, How to achieve multi-selection by pressing ctrl or shift? At the same time to know which line is selected.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear Krool, Excellent Grid control. I have tested the Demo with some variations and it works well. But when I compile the OCX, I am unable to register it on windows 10 (It is saying some dll library file is missing) or use it in my other applications. Where I could be going wrong?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear Krool, How do I distribute this wonderful OCX with my VB6 application. I am using Inno Setup5.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
amitabh srivastav
But when I compile the OCX, I am unable to register it on windows 10 (It is saying some dll library file is missing)
On latest builds of windows 10, in order to compile OCX/DLL, you need to run VB6 As Administrator.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi Krool,I want to implement the following functions:
For i = 1 To VBFlexGrid1.Rows - 1’Set the backcolor and forecolor of each row according to the conditions
If VBFlexGrid1.TextMatrix(i, 3) = -1 Then
VBFlexGrid1.RowBackColor(i) = vbRed
VBFlexGrid1.RowForeColor(i) = vbWhite
Else
BFlexGrid1.RowBackColor(i) = vbBlue
VBFlexGrid1.RowForeColor(i) = vbYellow
End If
Next i
VBFlexGrid1.AllowMultiSelection = True‘To press Ctrl and Shift to implement multiple selection
Can you implement this in the new version?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
@ ChenLin,
you could make a helper function like following:
Code:
Private Sub RowBackColor(ByVal FlexGrid As VBFlexGrid, ByVal iRow As Long)
Dim OldFillStyle As FlexFillStyleConstants
With FlexGrid
OldFillStyle = .FillStyle
.FillStyle = FlexFillStyleRepeat
.Cell(FlexCellBackColor, iRow, .FixedCols, , .Cols - 1) = vbRed
.FillStyle = OldFillStyle
End With
End Sub
Same then analog with ForeColor.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thanks Krool. The problem has been solved. I modify the color parameters and specify the colors directly:
Code:
Private Sub Command19_Click()
RowBackColor Me.VBFlexGrid1, 8
RowForceColor Me.VBFlexGrid1, 8
RowBackColor Me.VBFlexGrid1, 9, vbBlue
RowForceColor Me.VBFlexGrid1, 9, vbGreen
RowBackColor Me.VBFlexGrid1, 10, vbGreen
RowForceColor Me.VBFlexGrid1, 12, vbRed
End Sub
Private Sub RowBackColor(ByVal FlexGrid As VBFlexGrid, ByVal iRow As Long, Optional ByVal lColor As Long = vbRed)
Dim OldFillStyle As FlexFillStyleConstants
With FlexGrid
OldFillStyle = .FillStyle
.FillStyle = FlexFillStyleRepeat
.Cell(FlexCellBackColor, iRow, .FixedCols, , .Cols - 1) = lColor
.FillStyle = OldFillStyle
End With
End Sub
Private Sub RowForceColor(ByVal FlexGrid As VBFlexGrid, ByVal iRow As Long, Optional ByVal lColor As Long = vbBlack)
Dim OldFillStyle As FlexFillStyleConstants
With FlexGrid
OldFillStyle = .FillStyle
.FillStyle = FlexFillStyleRepeat
.Cell(FlexCellForeColor, iRow, .FixedCols, , .Cols - 1) = lColor
.FillStyle = OldFillStyle
End With
End Sub
Attachment 159099
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Press Ctrl and Shift MultiSelection to solve the problem (of course you can also use BigSelection to achieve), I hope useful to you.
Attachment 159115
Code:
Private Sub VBFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Long, j As Long
If Button = 1 Then
If Shift = 2 Then '按Ctrl键
With VBFlexGrid1
If .CellBackColor = &H8000000D Then
'取消选择这行
RowBackColor VBFlexGrid1, VBFlexGrid1.Row, IIf((i Mod 2) <> 0, &H80000005, RGB(227, 239, 218)) '修正点击后颜色不正确问题
RowForeColor VBFlexGrid1, VBFlexGrid1.Row, &H80000008
.RowData(.Row) = 0
Else
'选择这行
RowBackColor VBFlexGrid1, VBFlexGrid1.Row
RowForeColor VBFlexGrid1, VBFlexGrid1.Row
.RowData(.Row) = 1
End If
End With
ElseIf Shift = 1 Then '按Shift键
With VBFlexGrid1
If .Row <= .RowSel Then
For i = .Row To .RowSel
RowBackColor VBFlexGrid1, i
RowForeColor VBFlexGrid1, i
.RowData(i) = 1
Next
Else
For i = .Row To .RowSel Step -1
RowBackColor VBFlexGrid1, i
RowForeColor VBFlexGrid1, i
.RowData(i) = 1
Next
End If
End With
Else
'正常点击
End If
End If
End Sub
Private Sub VBFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Integer
Dim lngRow As Long, lngRowSel As Long
If Shift = 0 Then
With VBFlexGrid1
.Redraw = False
lngRow = .Row
lngRowSel = .RowSel
For i = 1 To .Rows - 1
If i <> lngRowSel And .RowData(i) = 1 Then
RowBackColor VBFlexGrid1, i, IIf((i Mod 2) <> 0, &H80000005, RGB(227, 239, 218)) '修正点击后颜色不正确问题
RowForeColor VBFlexGrid1, i, &H80000008
.RowData(i) = 0
End If
Next
.Row = lngRow
If .Row <= lngRowSel Then
For i = lngRow To lngRowSel
.RowData(i) = 1
RowBackColor VBFlexGrid1, i
RowForeColor VBFlexGrid1, i
Next
Else
For i = lngRow To lngRowSel Step -1
.RowData(i) = 1
RowBackColor VBFlexGrid1, i
RowForeColor VBFlexGrid1, i
Next
End If
.Redraw = True
End With
End If
End Sub
Public Sub RowBackColor(ByVal FlexGrid As VBFlexGrid, ByVal iRow As Long, Optional ByVal lColor As Long = &H8000000D)
Dim OldFillStyle As FlexFillStyleConstants
With FlexGrid
OldFillStyle = .FillStyle
.FillStyle = FlexFillStyleRepeat
.Cell(FlexCellBackColor, iRow, .FixedCols, , .Cols - 1) = lColor
.FillStyle = OldFillStyle
End With
End Sub
Public Sub RowForeColor(ByVal FlexGrid As VBFlexGrid, ByVal iRow As Long, Optional ByVal lColor As Long = &H8000000E)
Dim OldFillStyle As FlexFillStyleConstants
With FlexGrid
OldFillStyle = .FillStyle
.FillStyle = FlexFillStyleRepeat
.Cell(FlexCellForeColor, iRow, .FixedCols, , .Cols - 1) = lColor
.FillStyle = OldFillStyle
End With
End Sub
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Who has a good sorting method, please? I used to use it on Mshflexgrid, but I can't use it normally. Is it because I use Chinese characters?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
TopRow Add a New line to prevent errors when the mouse is rolled up.
Do not know if my method is wrong or a bug?
Code:
Public Property Let TopRow(ByVal Value As Long)
If Value < 0 Then Value = 0 'Add
If Value < 0 Or Value > (PropRows - 1) Then
err.Raise Number:=30009, Description:="Invalid Row value"
End If
Dim RCP As TROWCOLPARAMS
With RCP
.Mask = RCPM_TOPROW
.Flags = RCPF_CHECKTOPROW
.TopRow = Value
Call SetRowColParams(RCP)
End With
End Property
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
ChenLin
Who has a good sorting method, please? I used to use it on Mshflexgrid, but I can't use it normally. Is it because I use Chinese characters?
When you use any of FlexSortString... constants it should work as Wide API lstrcmp/lstrcmpi is used. What kind of problem do you have?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Tech99
Downloaded and briefly fiddled with this - looks very promising. Do you plan to support in-cell editing?
See this project with in-cell editing and formulas (Excel-like):
http://www.vbforums.com/showthread.p...=1#post5290223
P.S. VBFlexGrid OCX version
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
When you use any of FlexSortString... constants it should work as Wide API lstrcmp/lstrcmpi is used. What kind of problem do you have?
example code:
The problem is solved, the use is FlexSortStringNoCaseAscending, it is recommended that Chinese characters use this, numbers and money to use FlexSortCurrencyAscending
Code:
'排序函数
Public Sub Sort(Sgrd As VBFlexGrid)
IntSort = IntSort + 1
With Sgrd
If .MouseRow <> 0 Then Exit Sub '如果不是标题行就不排序
.Col = .MouseCol
Dim i As Integer
If IsNumeric(Sgrd.TextMatrix(1, Sgrd.MouseCol)) = True Then
.Sort = FlexSortCurrencyAscending + IntSort Mod 2 '按金额排序
Else
.Sort = FlexSortStringNoCaseAscending + IntSort Mod 2 '按字符排序
End If
.Col = 0 '这个为0避免排序后当前列之前为白色……
End With
End Sub
Welcome everyone to propose a better way!
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Basic question
In a populated grid, a left mouse click fires a SelChange.
Is there a simple way to fire the Selchange with the right mouse button as well?
Thanks
Karl
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Karl77
Basic question
In a populated grid, a left mouse click fires a SelChange.
Is there a simple way to fire the Selchange with the right mouse button as well?
I'm not sure what your goal is but it looks like you want to have a convenient way of span selection ranges with the right mouse button (?)
If yes here is a proposal:
Code:
Private Sub VBFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
With VBFlexGrid1
.HitTest X, Y
If .HitResult = FlexHitResultCell Then
If .HitRow > (.FixedRows - 1) And .HitCol > (.FixedCols - 1) Then
.RowSel = .HitRow
.ColSel = .HitCol
End If
End If
End With
End If
End Sub
If not, please advise.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Sorry for the unclear description.
It is about a single cell only.
I want to invoke a context menu.
This works ok now when I first select the cell by left click, and then do a right click.
If I right click only, then I get my context menu, but the cell where the click happened doesn't get selected before.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
In Farpoint Spread and my own Spread control, I can achieve Karl77's purpose by the following method:
Code:
Private Sub fpSpread1_RightClick(ByVal ClickType As Integer, ByVal Col As Long, ByVal Row As Long, ByVal MouseX As Long, ByVal MouseY As Long)
If ClickType = 1 Then '--- 0: MouseDown, 1: MouseUp ---
fpSpread1.SetActiveCell Col, Row
PopupMenu MnuTools
End If
End Sub
Maybe Krool could add the RightClick event for VBFlexGrid.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
The MS(H)FlexGrid control has MouseRow/MouseCol properties, these return the row/col which the mouse is hovering, without the need for a click or selecting the cells.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Just replaced RowSel to Row and ColSel to Col to get behavior of right click activating cell.
Also MouseUp instead MouseDown.
This should work, please try:
Code:
Private Sub VBFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
With VBFlexGrid1
.HitTest X, Y
If .HitResult = FlexHitResultCell Then
If .HitRow > (.FixedRows - 1) And .HitCol > (.FixedCols - 1) Then
.Row = .HitRow
.Col = .HitCol
PopupMenu MnuTools
End If
End If
End With
End If
End Sub
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
This should work, please try:
Code:
If .HitRow > (.FixedRows - 1) And .HitCol > (.FixedCols - 1) Then
.Row = .HitRow
.Col = .HitCol
Perfect.
Thank you.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Can anyone have a way to convert this to a VB.NET version? My VB.NET is still learning and currently has no ability to solve the problems that arise in the conversion.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Before I add the functionality by myself, a question.
Is there an edit function in the works?
I mean a textbox in a cell.
If not, it is ok.
To make the edit function is not so much effort.
I only don't want to re-invent the wheel if it's already in Krool's garage.
-
1 Attachment(s)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
A next question.
In Excel etc., when a cell is selected, the fixed rows/cols do highlight the cell coordinate.
Like this:
Attachment 160415
And when the control lost the focus, it should go away.
Would it be possible to have such a function inside the control?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Karl77
Is there an edit function in the works?
I mean a textbox in a cell.
Already there. See:
http://www.vbforums.com/showthread.p...=1#post5290225
;)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
gibra
Already there. See:
Aha, very cool.
A "bit" more than I wanted, but even better.
Thank you.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Karl77
A next question.
In Excel etc., when a cell is selected, the fixed rows/cols do highlight the cell coordinate.
Like this:
Attachment 160415
And when the control lost the focus, it should go away.
Would it be possible to have such a function inside the control?
Yes, you can implement such feature by following code addition into your Form:
Code:
Private Sub VBFlexGrid1_GotFocus()
Call SetRowColColorIndicator
End Sub
Private Sub VBFlexGrid1_LostFocus()
Call SetRowColColorIndicator(True)
End Sub
Private Sub VBFlexGrid1_RowColChange()
Call SetRowColColorIndicator
End Sub
Private Sub SetRowColColorIndicator(Optional ByVal Clear As Boolean)
Static LastRow As Long, LastCol As Long, InitDone As Boolean
With VBFlexGrid1
If InitDone = True Then
If LastRow > -1 Then .Cell(FlexCellBackColor, LastRow, 0) = -1
If LastCol > -1 Then .Cell(FlexCellBackColor, 0, LastCol) = -1
End If
If Clear = False Then
If .FixedCols > 0 Then
.Cell(FlexCellBackColor, .Row, 0) = vbRed
LastRow = .Row
Else
LastRow = -1
End If
If .FixedRows > 0 Then
.Cell(FlexCellBackColor, 0, .Col) = vbRed
LastCol = .Col
Else
LastCol = -1
End If
InitDone = True
Else
LastRow = -1
LastCol = -1
InitDone = False
End If
End With
End Sub
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Code:
Private Sub SetRowColColorIndicator
That works great.
I thought of adding such a feature into the control itself.
Now as I see it is a few lines only, it is very ok to have it in the form code.
Thank you.
Regarding the edit field the same applies.
It is, as said, not so much to do in the form code.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Internal GDI leak fixed. E.g. happen when the grid is loaded and unloaded dynamically many times.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Important update released.
The internal TEXTMETRIC structure was declared as ANSI and not as WIDE.
This bug has no functional effect on Unicode since the corrupted declaration is below the used section.
However, the WIDE API expects a larger structure than declared which is then a memory risk because the API will fill data beyond the declared structure. (not good)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
Important update released.
The internal TEXTMETRIC structure was declared as ANSI and not as WIDE.
This bug has no functional effect on Unicode since the corrupted declaration is below the used section.
However, the WIDE API expects a larger structure than declared which is then a memory risk because the API will fill data beyond the declared structure. (not good)
also affects CommonControls?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Jonney
also affects CommonControls?
Yes, but only ListBoxW Style <> Normal and new FontCombo.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Major performance boost in the internal GetHitTestInfo function.
This boost is only noticeable in very large grids, e.g. 500,000 rows.
Now the GetHitTestInfo function is same fast in a 500,000 rows grid then in a 100 rows grid.
Problem was if X or Y is below 0 then unnecessary iterations were performed. And the larger the grid the slower it gets. But this got now fixed.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Minor bugfix (1px miscalc) related to todays release for performance boost in the internal GitHitTestInfo function.
Worth mention is that the overall performance is boosted as the internal function is called often internally.
Therefore a 500,000 rows grid performs now quite good.
Next step is then virtual mode via custom data source to eliminate the long populate for such big row numbers.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I'm working currently with the FlexDataSource functionality where a custom data source can be set via IVBFlexDataSource interface.
As previously discussed in page 1 it's only for display of the viewport. (like virtual mode)
Therefore the Find and Sort functionality must be turned off as this is managed by the custom data source.
However, what about other functionalities like .Clip, .FormatString, .AddItem, .Clear, .TextMatrix ?
There would be a little overhead as it needs to be evaluated whether to call IVBFlexDataSource::GetData or read internal TCELL.
Or also disable .Clip, .FormatString etc. when custom data source is set ?
Anyhow, .TextMatrix needs to be kept as setting .TextMatrix could then invoke IVBFlexDataSource::SetData. If not there where else ?
Maybe Schmidt (Olaf) can advise how this works exactly in the vsFlexGrid.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
I'm working currently with the FlexDataSource functionality where a custom data source can be set via IVBFlexDataSource interface.
As previously discussed in page 1 it's only for display of the viewport. (like virtual mode)
Therefore the Find and Sort functionality must be turned off as this is managed by the custom data source.
However, what about other functionalities like .Clip, .FormatString, .AddItem, .Clear, .TextMatrix ?
There would be a little overhead as it needs to be evaluated whether to call IVBFlexDataSource::GetData or read internal TCELL.
Or also disable .Clip, .FormatString etc. when custom data source is set ?
Anyhow, .TextMatrix needs to be kept as setting .TextMatrix could then invoke IVBFlexDataSource::SetData. If not there where else ?
Maybe Schmidt (Olaf) can advise how this works exactly in the vsFlexGrid.
Can't say much with regards to .TextMatrix-Delegations (in both, read- and -write-directions),
because the whole point of an external DataSource is, to "not bother with storing data inside the Grid via TextMatrix".
And yes, sorting is done on the external Container (usually an Rs) - the only thing from the Grid we used
to trigger that, was "a Header-Click-Event".
And the "write-direction" of the external DS (::SetData) was triggered by "InCell-Edits" (not .TextMatrix)
(which the "big FlexGrid" allows).
Formatting was done via FlexGrid-Methods though (but not much - alternating Row-Colors mostly, along with ColWidth-settings).
We had only one case, where we needed "extensive Formatting" - and for that case we enabled
*also* the OwnerDraw-Mode on the Flex (in addition with using the external DS).
Olaf
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Great work Krool. I have replaced completely the MS flexgrid with yours and it's working great.
Quote:
Originally Posted by
Krool
Update, included ClipMode property that determines whether to include (default) or to exclude hidden cells in a clip command.
I tested this funcionality in the EXE version but in my programs I am using the ActiveX version and it is not included yet. Would you be so kind to add it in future versions ?
Thanks again, Miquel.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Schmidt
Can't say much with regards to .TextMatrix-Delegations (in both, read- and -write-directions),
because the whole point of an external DataSource is, to "not bother with storing data inside the Grid via TextMatrix".
And yes, sorting is done on the external Container (usually an Rs) - the only thing from the Grid we used
to trigger that, was "a Header-Click-Event".
And the "write-direction" of the external DS (::SetData) was triggered by "InCell-Edits" (not .TextMatrix)
(which the "big FlexGrid" allows).
Formatting was done via FlexGrid-Methods though (but not much - alternating Row-Colors mostly, along with ColWidth-settings).
We had only one case, where we needed "extensive Formatting" - and for that case we enabled
*also* the OwnerDraw-Mode on the Flex (in addition with using the external DS).
Olaf
Currently an intrinsic in-cell editing is not yet developed.
But for sure I would include ::SetData to be prepared interface wise already.
But can you maybe test in vsFlexGrid if a .TextMatrix delegation does fire a ::SetData ?
Because most MSFlexGrid users (which might migrate to VBFlexGrid) handle there in-cell edit by placing a external TextBox in cell location and need .TextMatrix therefore and for this case a call to ::SetData would be needed.
Another question: is the 'Record' Long param in ::GetData 1-based? The 'Field' param is for sure 0-based.
Thanks
Quote:
Originally Posted by
miquel
Great work Krool. I have replaced completely the MS flexgrid with yours and it's working great.
I tested this funcionality in the EXE version but in my programs I am using the ActiveX version and it is not included yet. Would you be so kind to add it in future versions ?
Thanks again, Miquel.
Yes, of course. In version 1.2.
But first a few other features need to be ready before.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
- Interface-Callback and mapping-wise it is all Zero-Based...
- FG.TextMatrix, as well as FG.Clip (and probably all other stuff) is routed to GetData/SetData of the DS-implementation, as soon as this was set.
Here is Test-Code for a small Form (which only contains a VSFlex, named F).
Code:
Private SArr As New cStringArrayDS
Private Sub Form_Load()
F.ColWidth(-1) = 1500
SArr.BindTo F, 3, 10
Dim x, y
For y = 0 To SArr.Rows - 1: For x = 0 To SArr.Cols - 1
SArr.Matrix(x, y) = "Row " & y & ", Col " & x
Next x, y
Debug.Print F.TextMatrix(2 + F.FixedRows, 2)
F.TextMatrix(2 + F.FixedRows, 2) = "2,2"
Debug.Print F.TextMatrix(2 + F.FixedRows, 2)
End Sub
Here a ScreenShot (with FixedCols an FixedRows both at 1):
http://vbRichClient.com/Downloads/FlexBinding.png
As one can see above, the TextMatrix-call is only matching with the SArr.Matrix-call,
when the current F.FixedRows are added to the Index-Position (in case F.FixedRows is > 0).
Only in x-Direction (addressing Cols), the zerobased indexes for SArr.Matrix and F.TextMatrix are matching -
so the DataSource ignores any current FixedRows-Header-Settings, whilst .TextMatrix wants the Header included in the x, y Offsets.
Ok, below is Code for the Binding-Class (named cStringArrayDS), which encapsulates a zerobased StringArray as the DataSource.
Code:
Option Explicit
Implements IVSFlexDataSource
Private mArr() As String
Public Sub BindTo(F As VSFlexGrid, ByVal Cols As Long, ByVal Rows As Long)
ReDim mArr(0 To Cols - 1, 0 To Rows - 1)
F.FlexDataSource = Me
End Sub
Public Property Get Rows() As Long
Rows = UBound(mArr, 2) + 1
End Property
Public Property Get Cols() As Long
Cols = UBound(mArr, 1) + 1
End Property
Public Property Get Matrix(ByVal xIdx As Long, ByVal yIdx As Long) As String
Matrix = mArr(xIdx, yIdx)
End Property
Public Property Let Matrix(ByVal xIdx As Long, ByVal yIdx As Long, RHS As String)
mArr(xIdx, yIdx) = RHS
End Property
'simple IVSFlexDataSource-implementation, which works against the internal array
Private Function IVSFlexDataSource_GetFieldName(ByVal Field As Long) As String
IVSFlexDataSource_GetFieldName = "ColHdr_" & Field
End Function
Private Function IVSFlexDataSource_GetFieldCount() As Long
IVSFlexDataSource_GetFieldCount = UBound(mArr, 1) + 1
End Function
Private Function IVSFlexDataSource_GetRecordCount() As Long
IVSFlexDataSource_GetRecordCount = UBound(mArr, 2) + 1
End Function
Private Function IVSFlexDataSource_GetData(ByVal Field As Long, ByVal Record As Long) As String
IVSFlexDataSource_GetData = mArr(Field, Record)
End Function
Private Sub IVSFlexDataSource_SetData(ByVal Field As Long, ByVal Record As Long, ByVal newData As String)
mArr(Field, Record) = newData
End Sub
HTH
Olaf
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
That's strange that the vsFlexGrid doesn't offset the FixedCols in the FlexDataSource.
When using the applying the DataSource (ADO recordset) then the fixed cols are also taken in consideration.
But for sake of compatibility I will replicate the behavior as like in the vsFlexGrid.
Thanks Schmidt for testing/pointing out the details.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi,
I like to see the selected Row/Col change in width.
here is what I added
Code:
'in the Form Header section:
Private DoColumnsResize As Boolean
'also
Private Sub Form_Activate()
DoColumnsResize = True
End Sub
'the Function:
Private Function mFlex_ColumnResize() As Boolean
Dim i As Long
Dim w As Single
Dim Row As Long
Dim Col As Long
Static backColor As Long
With VBFlexGrid1
.Redraw = False
Row = .Row
Col = .Col
'play with Value / 12 for width
w = (.Width - .ColWidth(0) - 290) / 12
.Row = 0
For i = 1 To .Cols - 1
.Col = i
If i <> Col Then
If .ColWidth(i) <> w Then
.ColWidth(i) = w
.CellForeColor = &H80000008
End If
Else
If .ColWidth(i) <> w * 2 Then
.ColWidth(i) = w * 2
.CellForeColor = vbBlue
End If
End If
Next
.Col = 0
For i = 1 To .Rows - 1
.Row = i
.CellBackColor = .BackColorFixed
If i = Row Then
.CellBackColor = &H80000018
End If
Next
.Row = Row
.Col = Col
.Redraw = True
End With
End Function
'and:
Private Sub VBFlexGrid1_RowColChange()
'set the widht
If DoColumnsResize Then
DoColumnsResize = False
mFlex_ColumnResize
DoColumnsResize = True
End If
End Sub
just my taste
regards
Chris
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Important bugfix concerning info tips and in-place label tips.
The internal tooltip had two problems. I described the second problem earlier in this thread. Both were solved by adding the WS_EX_TRANSPARENT style bit. It allows all mouse events to pass through.
1. When control A has focus and user hovers over the flexgrid B which shows a info tip or in-place label tip and the user clicks on that tip then the focus was not changing from A to B.
2. In Win10 the mouse wheel scroll did not work when the mouse hovered over an in-place tip.