VBFlexGrid Control (Replacement of the MSFlexGrid control)
This project is intended to replace the MSFlexGrid control for VB6.
The "MSFLXGRD.OCX" can be replaced completly.
Even though some enhancements of the MSHFlexGrid control are included, it can't replace it completly (yet).
But there are also new features included that are not available on both MSFlexGrid and MSHFlexGrid.
The VBFlexGrid supports Unicode, is DPI-Aware and ready for 64-bit.
At design-time (IDE) there is only one dependency. (OLEGuids.tlb)
This is a modified version of the original .tlb from the vbaccelerator website.
But for the compiled .exe there are no dependencies, because the .tlb gets then compiled into the executable.
In order to use the DataSource/DataMember property a reference to msdatsrc.tlb (pre-installed since Win2k) is required.
Everything should be self explained, because all functions and properties have a description.
The source code of the project can also be viewed on GitHub.
ActiveX Control version, together with a Registration-Free (Side-by-side) solution: Version 1.6
Notes:
- When using the SetParent or MoveWindow API, pass .hWndUserControl and not .hWnd.
- When changing the "Project Name", have all forms open, else all properties are lost. Because the library to which the controls are referring to is the "Project Name" itself. Having all forms open will ensure that the .frx files will be updated with the new "Project Name".
List of revisions:
Code:
29-Sep-2023
- Enhanced the internal DrawIncrementalSearch method so it can highlight multiple lines of word break text. (recursion)
28-Sep-2023
- Included the BeforeClipboardAction/AfterClipboardAction event.
Enum 'FlexClipboardActionConstants' included to distinguish between Copy, Cut, Paste and Delete.
The BeforePaste/AfterPaste event got removed.
- RowData/ColData property now 'As LongPtr' instead of 'As Long'.
27-Sep-2023
- Included the BeginIncrementalSearch/EndIncrementalSearch event.
The BeginIncrementalSearch event is fired initially to customize behavior. (row/col, case sensitive, no wrap etc.)
Or the Cancel parameter can be used to disallow incremental search for a specific row/col.
EndIncrementalSearch event is fired when the search has elapsed or ended.
Now BeginIncrementalSearch can be fired again.
- Included IncrementalSearchString/IncrementalSearchRow/IncrementalSearchCol run-time property.
25-Sep-2023
- Included the BeforePaste/AfterPaste event.
- Included the ParseClip/ConstructClip function.
ParseClip will parse a clip string into an two-dimensional array.
ConstructClip will construct a clip string from an two-dimensional array.
- Info and label tips now only shown when hit result is the cell content.
Thus a tool tip will not overlap anymore when the mouse is over a combo cue, check box etc.
- Bugfix in the Clip property when ClipPasteMode = FlexClipPasteModeAutoSelection and ClipMode = FlexClipModeExcludeHidden.
23-Sep-2023
- Included the AllowIncrementalSearch property.
- Included optional argument TextDisplay in the FindItem function.
- Added enum FlexFindDirectionRight/FlexFindDirectionLeft for the FindItem function.
16-Sep-2023
- Replaced 'Partial As Boolean' argument to 'Match As FlexFindMatchConstants' in the FindItem function.
Enums are FlexFindMatchExact, FlexFindMatchPartial, FlexFindMatchStartsWith, FlexFindMatchEndsWith.
vbTrue will be handled as FlexFindMatchPartial for compatibility.
14-Sep-2023
- Usage of hashes for the keys in the ColLookup property.
This ensure no more exponential performance decrease when there are more than 10 lookup entries.
13-Sep-2023
- Included the WallPaper/WallPaperAlignment property. (like in vsFlexGrid)
07-Sep-2023
- Included the ColComboCue property. (order is CellComboCue > ColComboCue > ComboCue)
ColComboCue excludes for fixed rows. Use the CellComboCue to fill the gap, if necessary.
- Added enum FlexComboCueHidden.
This may be useful to exclude cells in a ColComboCue via CellComboCue. (e.g. frozen row)
06-Sep-2023
- Included the EditLocked property.
03-Sep-2023
- Included the ColLookup property used to map keys to associated values.
This is useful for translating database values to user-friendly descriptions.
Example: (it can be used also without a combo list)
ColLookup(i) = ";NULL|0;|1;Full time|2;Part time|3;Contractor|4;Other"
ColComboItems(i) = "|Full time|Part time|Contractor|Other"
If a cell text is "3" then .Cell(FlexCellTextDisplay) will return "Contractor".
Choosing "Contractor" in the combo drop-down will put a cell text of "3".
01-Sep-2023
- Bugfix that LBN_SELCHANGE handler got misplaced in WM_COMMAND. (regression since 03-Nov-2021)
This resulted that arrow keys in the combo box did not update the edit text!
31-Aug-2023
- ColComboMode precede over ComboMode now. (like in vsFlexGrid)
This is now in sync as other properties. (e.g. ColComboButtonAlignment over ComboButtonAlignment)
29-Aug-2023
- Bugfix that the edit control back color did not consider the BackColorAlt property.
- Certain run-time properties now throw error 5 to avoid mis-use instead of silently doing nothing.
28-Jul-2023
- Bugfix in the ComboListIndex property that the new selection was not commited to the edit control.
22-Jul-2023
- Minor behavior bugfix for SelectionMode ByRow/ByColumn in relation to MS(H)FlexGrid.
15-Jul-2023
- FlexSortCustom now uses a indirect MergeSort instead of BubbleSort. (like FlexSortCustomText)
It is a bit slower than the normal MergeSort but compared to BubbleSort very fast.
08-Jul-2023
- CompareText event args fixed.
07-Jul-2023
- Modified OLEGuids.tlb as following: (compiled with same uuid)
- replaced LPSTR and LPWSTR to LONG StrPtr() to get compatibility with x64 OLEGuids twinBASIC package.
Unregister to old OLEGuids.tlb is not necessary, just overwrite the file.
01-Jul-2023
- PtInRect/LBItemFromPt/ChildWindowFromPoint API and code adaptions so it can be migrated to x64 more easily.
30-Jun-2023
- Missing invalidation fixed in the ColCheckBoxes property.
29-Jun-2023
- Memory leak fixed in the CellPicture property.
This is related to 26-Jun-2023 update.
28-Jun-2023
- Bugfix in the drawing of the text styles.
26-Jun-2023
- Major memory reduction for default formatted cells.
Once a cell gets custom formatted additional memory will be allocated.
It can only be freed by removing those cells or call .Clear method with FlexClearFormatting or FlexClearEverything.
- Major performance boost for AddItem/RemoveItem method.
The TCOL elements are now moved by the pointers only and not by copying the content over.
24-Jun-2023
- Major performance boost for InplaceMergeSort/BubbleSortIter (.Sort) and .RowPosition property.
The TCOL elements are now swapped by the pointers only and not by copying the content over.
23-Jun-2023
- Bugfix in the CellFloodColor property.
20-Jun-2023
- Memory consumption of TCELL struct reduced from 64 bytes to 52 bytes.
15-Jun-2023
- Bugfix for FlexCheckBoxAlignmentRightCenter.
13-Jun-2023
- FlexComboModeCalendar now behaves like FlexComboModeDropDown when the edit control has ES_READONLY.
It means always immediately popup of the calendar and commit on a date click.
11-Jun-2023
- No crash anymore for a NULL StrPtr() in EM_REPLACESEL. (EditSelText/FlexEditReasonBackSpace)
Though, the fix concerns only Windows XP or below.
31-Mar-2023
- Included ComboButtonClientWidth read-only property.
- Included ComboButtonWidth/ColComboButtonWidth run-time property.
28-Mar-2023
- Included ComboButtonPicture/ColComboButtonPicture run-time property which allows to customize the appearance of cell combo buttons.
Only applicable if the combo button draw mode property is set to 0 - Normal and the combo mode property is set to 3 - Button.
- Included Row/Col and Cancel parameter in the ComboButtonOwnerDraw event.
13-Mar-2023
- Included CheckBoxDrawMode run-time property and corresponding CheckBoxOwnerDraw event.
- Bugfix for FlexDisabledChecked when visual styles are off.
28-Feb-2023
- Added enum FlexCellTextDisplay for the Cell property.
- Included the FixedFormat property.
It defaults to vbNullString (StrPtr() = 0) and thus inherits from ColFormat.
Use "" to disable formatting for fixed cells in a column.
22-Feb-2023
- Included ColCheckBoxes property. (As Boolean; added CLIS_CHECKBOXES)
This allows a column to have predefined check boxes. (FlexNoCheckBox -> FlexUnchecked; fixed rows excluded)
- Included GetChecked/SetChecked to the IVBFlexDataSource2 interface.
Added FlexDataSourceChecked enum to FlexDataSourceFlags.
Only those columns with CLIS_CHECKBOXES will fetch from the custom data source.
- Added FlexNoCheckBoxEver enum to FlexCheckBoxConstants.
This allows to have no check box for individual cells even when ColCheckBoxes is set to True. (e.g. for frozen rows)
08-Feb-2023
- Internal 'UpdateEditRect' now takes the window sizes into account.
This makes it possible to use it not only for scroll updates but to use it also for other cases.
To call UpdateEditRect from outside just use the .Refresh method.
- Bugfix when canceling the BeforeUserResize event to return ProcessLButtonDown = True.
04-Feb-2023
- Included the ShowScrollTips property.
Use the ScrollTip event and ScrollTipText run-time property.
The scroll tip appears at the original thumb position and does not follow the thumb as the user scrolls.
If you prefer otherwise set the ScrollTipFollowThumb property to True.
28-Jan-2023
- Included the ColResizable/RowResizable property. (As Boolean; added CLIS_NOSIZING/RWIS_NOSIZING)
- Added FlexDataSourceNoData enum to FlexDataSourceFlags.
25-Jan-2023
- Added FlexRowSizingModeUniform enum to FlexRowSizingModeConstants.
Included related RowHeightUniform run-time property. The default value is -1 as disabled alias.
A uniform row height is applicable for all rows that do not have a specific height assigned to them.
23-Jan-2023
- Included ColCheckBoxAlignment/FixedCheckBoxAlignment property.
ColCheckBoxAlignment defaults to FlexCheckBoxAlignmentUsePictureAlignment.
FixedCheckBoxAlignment defaults to -1 and thus inherits from ColCheckBoxAlignment.
21-Jan-2023
- Added FlexDataSourceUnboundFixedColumns enum to FlexDataSourceFlags.
20-Jan-2023
- Setting FlexDataSource will predefine the column keys. (.ColKey(i) property, like vsFlexGrid)
- Included the IVBFlexDataSource2 interface that can be implemented in addition to the primary IVBFlexDataSource interface.
The new interface enables some further enhancements, but it may be extended in future releases.
18-Jan-2023
- Included the ColNullable property. (As Boolean; added CLIS_NULLABLE)
Setting ADO DataSource will predefine the information only property.
11-Jan-2023
- Added FlexTextAsCheckBox/FlexDisabledTextAsCheckBox enum to FlexCheckBoxConstants.
This maps the cell text to a check box state dynamically.
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.
07-Jan-2023
- Included the parameter 'Reason As FlexCellCheckReasonConstants' in the CellBeforeCheck event.
- Checkboxes now react on double click.
02-Jan-2023
- ComboCue/CheckBox now hot-tracked when MouseTrack property is set to True.
30-Dec-2022
- Included the ColNumericPrecision/ColNumericScale property. (As Byte)
Included the ColDataCapacity property. (As Long)
Setting ADO DataSource will predefine the column numeric precision/scale and data capacity.
It's an information property only, but useful to better format text or restrict max length in a column. (ColFormat/EditMaxLength property)
29-Dec-2022
- DIP metrics are converted to pixels now only once at UserControl_Initialize in new internal TPIXELMETRICS structure.
28-Dec-2022
- 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.
- Included BestFitMode property which defaults to 0 - TextOnly. (used for AutoSize/FormatString)
22-Dec-2022
- Added FlexDisabledUnchecked/FlexDisabledChecked/FlexDisabledGrayed enum to FlexCheckBoxConstants.
- New hit result FlexHitResultCheckBoxDisabled.
20-Dec-2022
- Included the Checkboxes feature. (CellChecked property)
Added enum FlexCellChecked for the Cell property.
Added hit result enum FlexHitResultCheckBox.
Included the CellBeforeCheck/CellCheck event.
This fires only by mouse click or space key. (not by code via CellChecked property)
17-Dec-2022
- The TextRect in the internal GetLabelInfo/GetTextHeight function now adjusted for potential ComboCue.
12-Dec-2022
- Cell flooding now also fills on selected cells.
Changed default FloodColor from &H80FF80 to &HC0& to be better readable on selections. (like vsFlexGrid)
11-Dec-2022
- Included the parameter 'CtlType As Long' in the ComboButtonOwnerDraw event.
09-Dec-2022
- Included the cell flooding feature. (CellFloodPercent/CellFloodColor/FloodColor property)
Added enum FlexCellFloodPercent and FlexCellFloodColor for the Cell property.
26-Nov-2022
- Minor bugfix in the internal GetLabelInfo method. (related to the ShowLabelTips property only)
16-Nov-2022
- Added enum 2 - IncludeFixedColumns and 3 - IncludeFixedAll for the ClipCopyMode property.
- Included the AutoClipboard property.
13-Nov-2022
- Included the ClipPasteMode property. Currently only 0 - Normal and 1 - AutoSelection.
10-Nov-2022
- Included the ClipSeparatorCol/ClipSeparatorRow run-time property. These default to vbTab and vbCr.
It can be useful to change the default and to support more than one character.
Example is the row separator vbCrLf for better MS Excel exchange.
However, if ClipSeparators property is set, then that will be used. (overwriting the default but limited to 1 character per)
09-Nov-2022
- Included the Copy/Cut/Paste/Delete method.
- Included the ClipCopyMode property. Currently only 0 - Normal and 1 - IncludeFixedRows.
This value affects the Copy method and the Clip Get-Property. (not the Clip Let-Property)
To have Clip Get/Let behave the same keep it as 0 - Normal.
23-Aug-2022
- The pen style for FlexFocusRectFlat uses now a NULL_BRUSH.
22-Aug-2022
- Bugfix in the RemoveItem method and Rows/Cols property.
08-Jun-2022
- Bugfix in the .RowPosition() and .ColPosition() property.
Now it is a round trip swap instead of a direct swap between index and value.
This behavior matches now to the MS(H)FlexGrid control.
30-May-2022
- Setting .FlexDataSource to nothing will invalidate the grid now and does not cause an immediate redraw anymore.
10-Jan-2022
- Bugfix in the AddItem method.
22-Dec-2021
- FlexAlignmentGeneral now aligns for dates to the right. (Like MS(H)FlexGrid)
Though FlexSortGenericAscending/FlexSortGenericDescending still sort either text or numeric number. (no dates like in MS(H)FlexGrid)
For dates keep using FlexSortDateAscending/FlexSortDateDescending.
13-Dec-2021
- Included the ComboButtonAlignment/ColComboButtonAlignment property.
ComboButtonAlignment defaults to 1 - Right and ColComboButtonAlignment defaults to -1 (inherit from ComboButtonAlignment).
This may be useful for right-to-left reading-order properties.
10-Dec-2021
- Included the MirrorAlignGeneral property.
This may be useful for right-to-left reading-order properties.
08-Dec-2021
- Included the ColDataType property. (As Integer; not restricted to an enum)
Setting ADO DataSource will predefine the column data type. (.ColDataType(i) property)
It's an information property only, intended to free the ColData property for other use cases.
07-Dec-2021
- Included the FixGridLineOffsets property.
It defaults to False to ensure visual compatibility with the MS(H)FlexGrid control.
01-Dec-2021
- Some minor internal improvements.
30-Nov-2021
- Merged rows/cols now drawn correctly in the freezing pane. (bugfixes in the internal DrawGrid routine)
29-Nov-2021
- User resizing of rows/columns not restricted to client rect bottom/right anymore.
This makes it easier to enlarge the last row/column beyond the client rect.
26-Nov-2021
- Included the GridColorFrozen/GridLinesFrozen/GridLineWidthFrozen property.
The GridLineWidthFrozen has an default value of -1, which means it exposes GridLineWidthFixed or GridLineWidth.
25-Nov-2021
- Included the SheetBorder property.
The default value is True which draws a border around the sheet. (Like MSFlexGrid)
When set to False it draws no such border. (Like MSHFlexGrid)
23-Nov-2021
- Included the GridLineWidthFixed property.
Like in the MSHFlexGrid it has an default value of -1, which means that it exposes the GridLineWidth property in that case.
- Included the FocusRectWidth property.
This has only an effect for FlexFocusRectFlat.
20-Nov-2021
- User now able to freeze even when fixed rows/cols are 0 and frozen rows/cols are 0.
19-Nov-2021
- The pen style for FlexFocusRectFlat is now PS_INSIDEFRAME instead of PS_SOLID.
PS_INSIDEFRAME is same as PS_SOLID but it keeps inside a given rectangle regardless of the pen width.
18-Nov-2021
- Included enum FlexFocusRectFlat for the FocusRect property.
It draws a solid rectangle (BackColorSel) instead of using the DrawFocusRect API.
16-Nov-2021
- Included the AllowMultiSelection property.
This property can only be set to True for SelectionMode 1 - ByRow or 3 - FreeByRow.
- Included the RowSelected/SelectedRow/SelectedRows run-time property.
These are automatically set when AllowMultiSelection is set to True.
However, they can be set by code even when AllowMultiSelection is set to False.
- Improved AllowSelection property (when set to False) to not restrict..
- ColSel for SelectionMode 1 - ByRow
- RowSel for SelectionMode 2 - ByColumn
10-Nov-2021
- Included the AllowScrollLock property.
When the scroll lock key is toggled on it allows the user to use the arrow keys to scroll. (like in Excel)
- SB_PAGE* scrolling fixed! (regression since 08-Sep-2021)
- Starting edit mode will now cancel any ongoing divider drag operation.
09-Nov-2021
- Escape key now cancels any ongoing divider drag operation.
08-Nov-2021
- Added edit reason enum FlexEditReasonComboCueAltUpDown.
06-Nov-2021
- Included the AllowUserFreezing property and the AfterUserFreeze event.
- Included a new AfterUserResizeEnd event. Unlike AfterUserResize which is before commit (ByRef NewSize As Long) this event is after the commit.
03-Nov-2021
- Minor performance improvement for the internal GetHitTestInfo function.
- Combo button now reacts to STN_DBLCLK.
02-Nov-2021
- Added combo cue enum FlexComboCueDisabledDropDown and FlexComboCueDisabledButton.
- Added hit result enum FlexHitResultComboCueDisabled.
- Included the CellComboCue property. (plus corresponding enum FlexCellComboCue)
This let's you define a fixed combo cue for an individual cell or a range of cells.
- Included the ComboCueRow/ComboCueCol property which sets the row and column where the combo cue is displayed.
Default internal value is -1 as an alias for the current focused cell. (.Row/.Col)
29-Oct-2021
- DC viewport for the ComboCue draw now set as 0, 0. (affects the ComboButtonOwnerDraw event)
28-Oct-2021
- Included the ComboCue property. (FlexComboCueConstants - which is 0 - None, 1 - DropDown or 2 - Button)
- New edit reason enum FlexEditReasonComboCueClick, FlexEditReasonComboCueDblClick and FlexEditReasonComboCueF4.
- New hit result enum FlexHitResultComboCue.
22-Oct-2021
- Added a new FlexComboModeCalendar enum that allows to use a drop-down calendar functionality when editing a cell.
The application must verify on ValidateEdit that the input is valid and also a unique format can be applied there. (see demo project)
18-Oct-2021
- Included the ColSortArrowAlignment property.
- Bugfix for the DoubleBuffer property and when both RightToLeft/RightToLeftLayout got toggled.
The DoubleBufferDC was not changed to either LAYOUT_RTL or 0 on WM_STYLECHANGED.
10-Oct-2021
- Included the ComboBeforeDropDown event.
09-Oct-2021
- The ellipsis on a ComboButton can now drawn with COLOR_GRAYTEXT when it is disabled.
05-Oct-2021
- Renamed FlexColSortArrowConstants into FlexSortArrowConstants.
04-Oct-2021
- Renamed enum FlexColSortArrowUp to FlexColSortArrowAscending and FlexColSortArrowDown to FlexColSortArrowDescending.
- Included the RowSortArrows property.
- Included the SortArrowColor property.
03-Oct-2021
- Included the ColSortArrowColor property.
01-Oct-2021
- Included the ColSortArrow property.
22-Sep-2021
- Performance improvement in the internal BubbleSortIter/InplaceMergeSort method. (UDT assignment)
18-Sep-2021
- Included the FlexSortCustomText enum with corresponding CompareText event.
10-Sep-2021
- Minor internal improvements in the internal SetScrollBars method.
08-Sep-2021
- Proportional thumb for the ScrollBars.
07-Sep-2021
- Included the ExtendLastCol property.
[...]
14-Jun-2017
- First release.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
List of enhancements and improvements in relation to the MSFlexGrid and/or MSHFlexGrid control:
Code:
- Scrolling beyond 65,535 rows possible. (16-bit barrier in MSHFlexGrid)
- Changing Row/Col property will respect the selection mode. (bug in MSFlexGrid and MSHFlexGrid)
- MouseWheel can be used to scroll. (limitation in MSFlexGrid and MSHFlexGrid)
- No cell count limit of 350000, only available memory space determines the cell count limit. (limitation in MSFlexGrid)
- FrozenRows/FrozenCols property included.
- AllowUserFreezing property included.
- AfterUserFreeze event included.
- RowSizingMode property included. (like in MSHFlexGrid)
- Align property included.
- DisableNoScroll property included.
- Added the Col param in the Compare event as it helps when doing multi-column sorts.
- WM_ERASEBKGND can be intercepted in a subclass to fill a custom background, if necessary.
- BackColorAlt property included to set alternate row back colors. (setting BackColor automatically sets BackColorAlt to the same value)
- DoubleBuffer property included.
- RightToLeft property included.
- AllowMultiSelection property included with related RowSelected/SelectedRow/SelectedRows property.
- AllowSelection property included.
- TabBehavior property included.
- DirectionAfterReturn property included.
- WantReturn property included.
- ExtendLastCol property included.
- SheetBorder property included. (Default is True to behave like MSFlexGrid else no border like MSHFlexGrid)
- WrapCellBehavior property included.
- ClipSeparators property included.
- ClipSeparatorCol/ClipSeparatorRow property (run-time only) included to change the defaults and to support more than 1 character for a separator.
- ClipMode property included to include (default) or exclude hidden cells in a clip command.
- ClipCopyMode property included to determine what parts are copied to the clipboard or returned by a clip command.
- ClipPasteMode property included to determine how content is pasted from the clipboard or by doing a clip command.
- ParseClip/ConstructClip function included. (parse/construct clip string into an/from an two-dimensional array)
- BeforePaste/AfterPaste event included.
- ShowInfoTips, ShowLabelTips and CellToolTipText property included.
- ShowScrollTips property included with related ScrollTip event and ScrollTipText property. (run-time only)
- ScrollTipFollowThumb property included.
- ScrollTrack property included.
- EllipsisFormat/EllipsisFormatFixed property included.
- Dashes/Dots enum included in the GridLine property. (like in MSHFlexGrid)
- FontFixed property included. (like in MSHFlexGrid)
- GridLineWidthFixed property included. (like in MSHFlexGrid)
- FixGridLineOffsets property included.
- MirrorAlignGeneral property included.
- SingleLine property included.
- Flat enum included in the FocusRect property.
- Cell property included which allows to get or set cell settings directly for an arbitrary cell or range of cells without selecting them.
- CellTextStyle returns the TextStyle/TextStyleFixed from the Control when not preset instead of 0.
- CellAlignment returns the alignment from the column (ColAlignment or FixedAlignment) when not preset instead of 0.
- CellBackColor/CellForeColor returns the BackColor/ForeColor from the Control when not preset instead of 0.
- CellTextStyle/CellAlignment/CellBackColor/CellForeColor are not preset anymore when setting a value of -1.
- CellChecked property for checkboxes along with CellBeforeCheck/CellCheck event.
- ColCheckBoxAlignment/FixedCheckBoxAlignment/ColCheckBoxes property included.
- CheckBoxDrawMode property included and corresponding CheckBoxOwnerDraw event.
- ColWidthMin property included. (analogous to the RowHeightMin property)
- RowHeightMax/ColWidthMax property included.
- RowHeightUniform (run-time only) property included. (for use with FlexRowSizingModeUniform)
- MouseEnter/MouseLeave event included.
- HitTest method included with a specified X and Y. The return values are in the HitRow/HitCol/HitRowDivider/HitColDivider/HitResult property.
- FindItem function included.
- FixedAlignment property accepts an index of -1 (like ColAlignment) to apply the value to all columns.
- FixedAlignment is not preset anymore when setting a value of -1.
- Mouse cursor is now clipped when user resizing rows and columns.
- CellEnsureVisible method included with optional visibility parameter. (default is FlexVisibilityCompleteOnly)
- BottomRow/RightCol property included with optional visibility parameter. (default is FlexVisibilityPartialOK)
- RowsVisible/ColsVisible/FixedRowsVisible/FixedColsVisible/FrozenRowsVisible/FrozenColsVisible property with an optional visibility parameter. (default is FlexVisibilityCompleteOnly)
- RowIsVisible/ColIsVisible property optional visibility parameter included. (default is FlexVisibilityPartialOK)
- RowHidden/ColHidden property included. (same as RowHeight/ColWidth set to 0, but this approach preserves the original setting)
- ColKey/ColIndex and RowID/RowIndex property included. (used to identify specified column/row)
- ColDataType/ColNullable/ColNumericPrecision/ColNumericScale/ColDataCapacity property included.
- ColResizable property included.
- ColLookup property included.
- ColFormat/FixedFormat property included.
- RowsPerPage/ColsPerPage property included that returns the number of non-fixed columns/rows displayed on the current page to scroll through. (no visibility parameter here)
- GetSelRange method included to retrieve selection range of cells ordered so that Row1 <= Row2 and Col1 <= Col2.
- SelectRange method which selects a range of cells or a cell (by omitting RowSel/ColSel) with a single command.
- GetMergedRange method included to retrieve the merged cells on a given row/col.
- SelChange event is also fired while the user extends the selection with the mouse. (limitation in MSFlexGrid and MSHFlexGrid)
- Scroll event is fired whenever the TopRow/LeftCol property changes. (limitation in MSFlexGrid and MSHFlexGrid)
- BeforeUserResize/AfterUserResize/AfterUserResizeEnd event included.
- BeforeRowColChange/BeforeSelChange event included.
- Copy/Cut/Paste/Delete method, AutoClipboard property and BeforeClipboardAction/AfterClipboardAction event.
- Clear method optional Where/What parameter included.
- When MergeCells is set to a value other than 0 (Never), selection highlighting is still possible. (limitation in MSFlexGrid and MSHFlexGrid)
- MergeCells can span multiple rows and columns together. (limitation or bug in MSFlexGrid and MSHFlexGrid)
- FixedOnly enum included in the MergeCells property.
- UseColSort enum included in the Sort property and corresponding ColSort property included.
- ColSortArrow/ColSortArrowAlignment/ColSortArrowColor property included.
- SortArrowColor/RowSortArrows property included.
- CurrencyAscending/CurrencyDescending and DateAscending/DateDescending enum included in the Sort/ColSort property.
- CellFloodPercent/CellFloodColor/FloodColor property included.
- AutoSize method included.
- BestFitMode property included which is used for AutoSize/FormatString.
- WallPaper/WallPaperAlignment property included.
- AllowIncrementalSearch property included with events and run-time properties. (incremental search functionality)
- TextWidth/TextHeight function included.
- DividerDblClick event included.
- DataRefresh method included.
- FlexDataSource property (run-time only) included to set a custom data source via the IVBFlexDataSource interface.
- AllowUserEditing property included with events and run-time properties. (in-cell editing functionality)
- AllowScrollLock property to check the toggled state of vbKeyScrollLock to let the users use the arrow keys to scroll. (like in Excel)
- Some other minor improvements.
List of incompatibilities in relation to the MSFlexGrid control:
Code:
- FontWidth and CellFontWidth property not implemented.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Very much and need this OCX to support print preview and paging? There is a great need for this feature: you can directly set the image read from the database and display it in each cell.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by ChenLin
Very much and need this OCX to support print preview and paging?
There will be no OCX for the moment as I want to wait a certain period for potential bugfixes etc. (trial period)
You can make your own Print Preview. You can extract via the .Picture property a StdPicture object which holds a "printed" content of the grid.
However it prints always the whole grid (like in MSFlexGrid). However, when there is a need to include optional parameters to "print" only a part (e.g. current view) then we can look further.
What do you mean by paging?
Again this is certainly a job for the app to break according to printer settings etc.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Paging I have done using SQL SERVER, the main thing is to show the image in the database, MSHFLEXGRID is not very convenient to display the image in the database.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hello Krool,
I just tried your VBFlexGrid, I was surprised how easy it was to change
my code from MsFlexGrid to VBFlexgrid. And the Project executed with now faults.
here is what I tried out and what I had to change, I marked my changes
like this:
'// had to change this
'.CellAlignment = flexAlignCenterCenter
'// to :
in Modul:
Code:
Option Explicit
Public Sub KalenderFlexShow(Flex As VBFlexGrid, Jahr As Long)
Dim i As Long, j As Long
Dim Days As Long
Dim Datum As Date
With Flex
.Redraw = False
.Rows = 33
.Cols = 14
.FixedCols = 0
.FixedRows = 2
.Clear
.TextMatrix(0, 0) = CStr(Jahr - 1)
.TextMatrix(1, 0) = MonthName(12)
For i = 1 To 12
.TextMatrix(0, i) = CStr(Jahr)
.TextMatrix(1, i) = MonthName(i)
Next
.TextMatrix(0, 13) = CStr(Jahr + 1)
.TextMatrix(1, 13) = MonthName(1)
.Row = 0
For i = 0 To .Cols - 1
.Col = i
'// had to change this
'.CellAlignment = flexAlignCenterCenter
'// to :
.CellAlignment = FlexAlignmentCenterCenter
Next
For i = 1 To 12
KalenderFlexMonat Flex, i, Jahr, i
Next
KalenderFlexMonat Flex, 12, Jahr - 1, 0
KalenderFlexMonat Flex, 1, Jahr + 1, 13
If Jahr = Year(Now) Then
.Col = Month(Now)
.Row = Day(Now) + 1
ElseIf (Jahr = Year(Now) - 1) And (Month(Now) = 12) Then
.Col = 0
.Row = Day(Now) + 1
ElseIf (Jahr = Year(Now) + 1) And (Month(Now) = 1) Then
.Col = 13
.Row = Day(Now) + 1
Else
.Col = 1
.Row = 0
End If
.Redraw = True
End With
End Sub
Private Sub KalenderFlexMonat(Flex As VBFlexGrid, Monat As Long, _
Jahr As Long, Col As Long)
Dim Days As Long, i As Long
Dim Datum As Date
Dim s As String
Datum = DateSerial(Jahr, Monat, 1)
Days = Day(DateAdd("m", 1, Datum) - 1)
With Flex
.Col = Col
For i = 1 To Days
.Row = i + 1
s = Format(i, "00") & Space(2)
If Weekday(Datum, vbMonday) = 7 Then
s = s & Format(Datum, "ddd")
.CellForeColor = vbRed
Else
s = s & Format(Datum, "ddd")
.CellForeColor = vbBlack
End If
.Text = s
'// had to change this
'.CellAlignment = flexAlignLeftCenter
'// to :
.CellAlignment = FlexAlignmentLeftCenter
Datum = Datum + 1
Next
End With
End Sub
in Form:
Code:
Option Explicit
Private Sub Command1_Click()
Dim s As String
s = InputBox("Jahr eingeben", "Kalender", Year(Now))
If Len(s) = 0 Then
Exit Sub
ElseIf Not IsNumeric(s) Then
Exit Sub
End If
KalenderFlexShow VBFlexGrid1, Val(s)
End Sub
Private Sub Form_Load()
With VBFlexGrid1
' .FocusRect = flexFocusHeavy
.FocusRect = FlexFocusRectHeavy
.BackColorBkg = Me.BackColor
.AllowBigSelection = False
' .SelectionMode = flexSelectionFree
.SelectionMode = FlexSelectionModeFree
End With
KalenderFlexShow VBFlexGrid1, Year(Now)
End Sub
Private Sub Form_Resize()
If Me.WindowState = vbMinimized Then
Exit Sub
End If
On Error Resume Next
With VBFlexGrid1
.Top = 300
.Left = 0
.Width = Me.ScaleWidth
.Height = Me.ScaleHeight - .Top
End With
On Error GoTo 0
End Sub
I haven't looked threw your complete List of enhancements and improvements
but for the first test I am impressed!!!!!!!
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by DEXWERX
2 questions:
Are you going to implement data binding?
How would you implement a virtual/on demand data source?
It is planned to be implemented.
1. Making the UserControl.DataBindingBehavior set to 'vbComplexBound' and provide a 'DataSource' and 'DataMember' property. (like in MSHFlexGrid, only ADO)
However, that needs to include the 'msdatsrc.tlb' type library and expose its DataSource interface. (=Dependency; as exposed publicly)
So I need to check if there would be no issue to make such a "dependency" with the 'msdatasrc.tlb' type library. It is part of MDAC, which should be pre-installed since Windows 2000. Or am I wrong?
2. Providing a run-time .Recordset property (Also like in MSHFlexGrid, could be 'As Object' thus supporting both DAO and ADO Recordsets)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I'm using the vsFlexGrid control and this control has quick access to ranges of cells to change the layout and content.
So instead of settings ROW, COL, ROWSEL, COLSEL and FILLSTYLE you just specify the range of the cells on which a method is executed, advantage that you don't have to change the active selection to modify cell content/layout.
Idea for vbFlexGrid replacements for Cell* with Range* like:
RangeFontBold(Row1, Col1, Row2, Col2)
RangeForeColor(Row1, Col1, Row2, Col2)
PS
The vsFlexGrid control uses a different method using a single .Cell() method, in which you also specify what you want to do.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Arnoutdv
So instead of settings ROW, COL, ROWSEL, COLSEL and FILLSTYLE you just specify the range of the cells on which a method is executed, advantage that you don't have to change the active selection to modify cell content/layout.
Good idea, thanks. Update released.
Included the Cell property which allows to get or set cell settings directly for an arbitrary cell or range of cells without selecting them.
However, when setting a range of cells via the Cell property it is dependent like in the normal Cell* properties how the FillStyle property is defined.
So if FillStyle is Single you can select a range via the Cell property it will only set the arbitrary cell and not the selection. (Exception is when setting the Clip property via the Cell property)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hello Krool
would it make sense to Hardcode some Funtions in the Grid ?
like the Routine I used to create the Calendar, you would the just call somthing like
Code:
VBFlexGrid1.KalenderFlexShow,Year(Now)
in regards to loading Data from a Database, I would do the same thing
one for ADO Recordsets and one for DAO.
something like this..
Code:
'ADO Version
Public Function FlexFillFromRs(Rs As ADODB.Recordset, _
Flex As MSFlexGrid)
'loading Recordset
Dim i As Long
Dim j As Long
Dim breit As Single
With Flex
.Redraw = False
.AllowBigSelection = True
.AllowUserResizing = flexResizeBoth
.Appearance = flex3D
.FocusRect = flexFocusNone
.FixedRows = 1
.FixedCols = 1
'count cols
.Cols = Rs.Fields.Count
'Headers
For i = 0 To Rs.Fields.Count - 1
.TextMatrix(0, i) = Rs.Fields(i).Name
Next
'count rows
.Rows = .FixedRows + Rs.RecordCount + 1
'fill Flex
Do While Not Rs.EOF
'Records
i = Rs.AbsolutePosition
For j = 0 To Rs.Fields.Count - 1
'Abfrage auf NULL
If Not IsNull(Rs.Fields(j).Value) Then
.TextMatrix(i, j) = Rs.Fields(j).Value
End If
Next
Rs.MoveNext
Loop
'optimise width
For i = 0 To .Cols - 1
breit = 0
For j = 0 To .Rows - 1
If Me.TextWidth(.TextMatrix(j, i)) > breit Then
breit = Me.TextWidth(.TextMatrix(j, i))
End If
Next
.ColWidth(i) = breit + 120
Next
.Redraw = True
End With
End Function
then you would just have to pass a valid ADO Recordset and Connection to the Grid like..
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I just downloaded and tried - VERY NICE
There may be quite a few of us that don't need Unicode, and thus may not have bothered downloading your contribution.
However if the title of your thread had been -
VBFlexGrid User Control (Replacement of the MSFlexGrid control)
And there had been a bit more emphasis on NO DEPENDENCIES
I would have downloaded it before the ink on your OP had dried
Thanks for sharing,
Rob
PS The Printscreen to Clipboard ain't too shabby either
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Bobbles
There may be quite a few of us that don't need Unicode, and thus may not have bothered downloading your contribution.
However if the title of your thread had been -
VBFlexGrid User Control (Replacement of the MSFlexGrid control)
And there had been a bit more emphasis on NO DEPENDENCIES
I would have downloaded it before the ink on your OP had dried
It is not only for Unicode. For me personally it was important to get some annoying bugs fixed and be indepedent of any OCX. And of course the additional features.
For the thread title: UserControl would be even more directly, True. But I want to keep the wording dual-use as after this Std-EXE version there will also be an ActiveX Version (OCX), after a certain trial period.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
can you add a VirtualMode to the demo when it's ready?
ie: let's say you're scrolling through a half a million records, but you really only want to provide the data to the control when it's scrolled into view.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by DEXWERX
can you add a VirtualMode to the demo when it's ready?
ie: let's say you're scrolling through a half a million records, but you really only want to provide the data to the control when it's scrolled into view.
To properly implement that, I'd suggest the exact same Interface (also IID-wise), as the vsFlexGrid is using
(IVSFlexDataSource, ...it is a nice and small one - despite being universal for all kinds of "Data with Header-Descriptions"):
In the vsFlexGrid, VB6-Classes which implement it, are then used together with the vsFG.FlexDataSource-Property (of Type IVSFlexDataSource),
to address external Data of DAO-, ADO- or SQLite-Recordsets, or just plain String- or Variant-Arrays outside the Control.
Note that the vsFlexGrid.FlexDataSource-Prop is exposed as only a Get/Let-pair (just mentioning it,
since that might irritate some VB6-devs, because it's a bit unusual, not being allowed to use a Property Set
when passing an Object into a Control (so, perhaps best, to implement it as a "full VB6-Triple-Prop" Get/Let/Set)...
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Schmidt
To properly implement that, I'd suggest the exact same Interface (also IID-wise), as the vsFlexGrid is using
(IVSFlexDataSource, ...it is a nice and small one - despite being universal for all kinds of "Data with Header-Descriptions"):
In the vsFlexGrid, VB6-Classes which implement it, are then used together with the vsFG.FlexDataSource-Property (of Type IVSFlexDataSource),
to address external Data of DAO-, ADO- or SQLite-Recordsets, or just plain String- or Variant-Arrays outside the Control.
Note that the vsFlexGrid.FlexDataSource-Prop is exposed as only a Get/Let-pair (just mentioning it,
since that might irritate some VB6-devs, because it's a bit unusual, not being allowed to use a Property Set
when passing an Object into a Control (so, perhaps best, to implement it as a "full VB6-Triple-Prop" Get/Let/Set)...
Good suggestion, thanks. But exposing an type lib interface with a public property brings type lib dependency in a later potential OCX...
IMO would be a simple classic "event mechanism" for virtual data be sufficient? or would I overlook something in that case?
Or put the type lib interface in a "like-wise" VB6 class.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
Good suggestion, thanks. But exposing an type lib interface with a public property brings type lib dependency in a later potential OCX...
IMO would be a simple classic "event mechanism" for virtual data be sufficient? or would I overlook something in that case?
Or put the type lib interface in a "like-wise" VB6 class.
The latter one (a simple interface-defining VBClass with the name IVSFlexDataSource would be sufficient) -
I've just looked into our Project-Codes, the implementing Classes are all quite small Private ones in our Projects,
so the exact same IID of the original Interface wouldn't be that important in our cases as I thought,
just "Signature compatibility" would be enough).
A (Latebound working) Event-mechanism could also do (performance not being such a critical factor here,
since the "visible Rows and Cols" of the currently scrolled "ViewPort" are not all that many...
In case of an (then earlybound) true Interface-Class, you could also enclose the points where you expect an "IVSFlexDataSource"-
implementing Object in compiler-conditionals (#If CompileWithFlexDataSourceSupport .... or something, in the non-OCX-version).
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Schmidt
A (Latebound working) Event-mechanism could also do (performance not being such a critical factor here,
since the "visible Rows and Cols" of the currently scrolled "ViewPort" are not all that many...
When there is a "search" trough a find function does it callback all items via GetData or is there is special callback (like LVN_ODFINDITEM style) where the client is responsible to return the found row/index?
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I've always had to code custom search/find for the MSHFlexGrid anyway. (not sure)
For efficiency I would think the LVN_ODFINDITEM approach would be best.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by DEXWERX
I've always had to code custom search/find for the MSHFlexGrid anyway. (not sure)
For efficiency I would think the LVN_ODFINDITEM approach would be best.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
And the same for a Sort?
I'd not bother with Find and Sort (delegations) in case of external FlexDataSource-Data.
The reason a developer is working with such an external DataSource is (beside others),
that he probably wants to sort, filter, search the external containers much more comfortably (and faster) on their own
(without any "help from a Grid-control").
A Grid is mainly for managing and rendering the ViewPort, nothing much else.
If I want external Data sorted in the vsFlexGrid I do it on the Rs or the Array itself -
and then refresh the DataSource (which in this case only enforces a new rendering of the viewport).
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Schmidt
I'd not bother with Find and Sort (delegations) in case of external FlexDataSource-Data.
The reason a developer is working with such an external DataSource is (beside others),
that he probably wants to sort, filter, search the external containers much more comfortably (and faster) on their own
(without any "help from a Grid-control").
A Grid is mainly for managing and rendering the ViewPort, nothing much else.
If I want external Data sorted in the vsFlexGrid I do it on the Rs or the Array itself -
and then refresh the DataSource (which in this case only enforces a new rendering of the viewport).
Exactly. Just like in a ListBox with LBS_NODATA it is not possible to add LBS_SORT.
Therefore in the FlexGrid the .FindItem and .Sort functionality just needs to be "disabled" by an error raise in case VirtualMode is turned on. (=Solved)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
One further question for VirtualMode layout.
What Schmidt suggested for the FlexDataSource interface means actually always 1 fixed row (field name) and 0 fixed columns.
The GetFieldCount method would define the number of columns and the GetRecordCount the number of rows.
However, that means I also need to disable the Rows/Cols and FixedRows/FixedCols properties.
OR instead they are allowed (flexible) and just a 'RetrieveVirtualItem' event would be fired for all cells in viewport, regardless if they are 2 fixed rows or none. I think that would be a very flexible approach?
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
yes, you definitely don't want to lock fixed cells.
Fixed cells are often used for row numbers or other indicators, which also need to be populated in virtualmode.
It's a good idea to use the event/callback for all cells including fixed.
you could also use a single call for the entire window update - as opposed to each cell. (just an idea)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
The GetFieldCount method would define the number of columns and the GetRecordCount the number of rows.
However, that means I also need to disable the Rows/Cols and FixedRows/FixedCols properties.
OR instead they are allowed (flexible) and just a 'RetrieveVirtualItem' event would be fired for all cells in viewport, ...
Sure, the vsFlexGrid allows free settings on the FixedRows/FixedCols also in "FlexDataSource"-mode...
(the FixedRows-setting not affecting the Zerobased "Record-Param" which is passed into the Callback).
Code:
Private Function IVSFlexDataSource_GetData(Byval Field As Long, ByVal Record As Long) As String
IVSFlexDataSource_GetData = RsSQLite.ValueMatrix(Record, Field) 'example for providing the Data from an SQLite-Recordset
End Function
It's just that the CallBack-Function in IVSFlexDataSource will be called for *only* the currently *visible* cells
of the (potentially scrolled) Viewport-area (leaving "skipped gaps" between the zerobased FixedCol-indexes and the
Col (Field) indexes of the scrollable Cells).
You have to manage these "skips" internally when raising your Event or Callback (so that the Callback is not
called unnecessarily for any cells which are currently not scrolled into the ViewPort).
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Updated released.
Included the DataSource/DataMember property. The properties can be set at design-time and/or at run-time.
The Adodc control, an DateEnvironment designer and a ordinary ADODB.Recordset object have been tested and are thus supported.
If somebody don't want to use the new feature and want to avoid a reference to msdatsrc.tlb (pre-installed since Win2k) the whole thing can be turned off by setting the new conditional compilation constant 'ImplementDataSource' to False.
When doing so (turn off) the 'DataBindingBehavior' might be changed back from 'vbComplexBound' to 'vbNone'.
What is still missing is a run-time only 'Recordset' property. (like in MSHFlexGrid)
But here I am still uncertain of how to best implement it and if and how to interact with the now implemented 'DataSource' property.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
Did you put the OLEGuids.tlb in the SysWOW64 system folder?
Also try to reference the file with Browse..
That's already done, but still not. The prompt version is incompatible, unable to register, and cannot refer to this TLB in VB6K.
I referenced other OLEGuids.tlb, except for the function of "Show Property Pages".
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by ChenLin
That's already done, but still not. The prompt version is incompatible, unable to register, and cannot refer to this TLB in VB6K.
I referenced other OLEGuids.tlb, except for the function of "Show Property Pages".
Which other OLEGuids?
In case you have multiple versions you can name this version OLEGuids2 and reference accordingly.
This version is equal to the ComCtls version.
Last year there was a new version released with new uuid. If you have an older version you might "unregister" that first.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
Which other OLEGuids?
In case you have multiple versions you can name this version OLEGuids2 and reference accordingly.
This version is equal to the ComCtls version.
Last year there was a new version released with new uuid. If you have an older version you might "unregister" that first.
TLB the problem is solved, and I did this: use this TLB to override the TLB in the system.