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
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
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
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
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
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!
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by TheLeePiper
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)
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.)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by TheLeePiper
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.
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)
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?
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:
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.
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!
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.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
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.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by DaveDavis
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?
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
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.
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.
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
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by hl88
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
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)
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.
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)
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.
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 :-(
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 aComboEditable 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
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by softv
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 aComboEditable 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
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.