Page 1 of 20 123411 ... LastLast
Results 1 to 40 of 797

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    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 and is DPI-Aware.

    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.5

    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:
    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.
    18-Aug-2021
    - Bugfixes (side-effects) related of FrozenRows/FrozenCols for BottomRow/RightCol property.
    - Bugfix in the internal GetHitTestInfo function.
      Now an adjustment is done between the leftmost/topmost column/row and the non-scrollable columns/rows.
      This affecty only for hit tests of divider column left and row top. (divider column right and row bottom not affected)
    03-May-2021
    - Removed WS_EX_NOPARENTNOTIFY in the window creation as this causes a MDI child window to not get activated.
    26-Mar-2021
    - UserControl.DrawStyle set to 5 = Transparent to avoid a wasted/unused GDI pen handle.
    17-Mar-2021
    - Improved CreateGDIFontFromOLEFont function.
    12-Mar-2021
    - Included the SelectRange method.
      This method selects a range of cells or a cell (by omitting RowSel/ColSel) with a single command.
    08-Mar-2021
    - AutoSize method works now as expected if WordWrap = True and Mode = FlexAutoSizeModeRowHeight.
    - AutoSize method works now also as expected if SingleLine = True.
    06-Mar-2021
    - Bugfixes (side-effects) related of FrozenRows/FrozenCols for other properties.
    - Included FrozenRowsVisible/FrozenColsVisible property.
    - Included the enum FlexAutoSizeScopeMovable/FlexAutoSizeScopeFrozen in the AutoSize method.
      FlexAutoSizeScopeScrollable will not autosize the frozen cells.
      FlexAutoSizeScopeMovable contains both frozen and scrollable cells.
    - Included the enum FlexClearMovable/FlexClearFrozen in the Clear method.
      FlexClearScrollable will not clear the frozen cells.
      FlexClearMovable contains both frozen and scrollable cells.
    05-Mar-2021
    - Included the FrozenRows/FrozenCols property.
    - Bugfix in the ValidateEdit event when showing a message box inside the event.
    02-Mar-2021
    - The TextHeight function does not return 0 anymore when passing an empty string.
      Instead it returns TMHeight (TEXTMETRIC). TextWidth is unchanged and keeps returning 0 on an empty string.
      This behavior is now the same as in a VB.Form's TextHeight/TextWidth function.
    28-Feb-2021
    - Included new enum 'FlexMousePointerConstants' which the MousePointer property now uses.
      Reason is that the VBA environment does not support IPerPropertyBrowsing.
    - Included the EditContextMenu event.
    27-Feb-2021
    - Bugfix in the AutoSize method when using IVBFlexDataSource.
    - FindItem function can now be used (not disabled anymore) when using IVBFlexDataSource.
    - Some minor internal improvements.
    25-Feb-2021
    - Some minor internal improvements.
    26-Jan-2021
    - FixedRows property now using RCPF_FORCETOPROWMASK.
    - FixedCols property now using RCPF_FORCELEFTCOLMASK.
    - Rows/Cols/FixedRows/FixedCols property now using RCPF_FORCEREDRAW.
    17-Nov-2020
    - Setting ADO DataSource will predefine the column keys. (.ColKey(i) property)
    14-Nov-2020
    - Exception for Rows/Cols property to be able to scroll, if necessary.
      This is related to 13-Nov-2020 update.
    13-Nov-2020
    - Bugfix that the ScrollBars property did not made a limitation for the scrolling.
      This is the same behavior now as in the in the MS(H)FlexGrid control.
    11-Aug-2020
    - Bugfix in the ForeColorFixed property.
    09-Aug-2020
    - OCX supports accelerator keys in a VBA environment.
    02-Aug-2020
    - Internal function ComboShowDropDown will call RefreshMousePointer function when current hCursor is NULL.
    05-Jul-2020
    - The ellipsis on a ComboButton can now drawn with COLOR_HOTLIGHT when mouse is over it.
      This only affects when visual styles are off.
    28-May-2020
    - WM_UNICHAR handler now supports surrogate pairs. (UTF32 conversion)
    26-May-2020
    - Massive performance boost for Get .Clip property.
      The string concatenation was done by using small buffer chunks putting together.
      Now the VB6 poor man's string builder is used from wqweto. (but using a string array instead of a collection)
    13-May-2020
    - Performance boost for drawing custom cell background colors.
    11-May-2020
    - CS_VREDRAW and CS_HREDRAW are not specified anymore as entire redraw upon resize is not necessary.
    10-May-2020
    - Performance boost for drawing the grid.
      - ~2% for using of Polyline API (not PolylineTo !) instead of MoveToEx and LineTo. (for the grid lines)
        Polyline is at device driver level, thus faster than LineTo and it doesn't change current position.
      - ~1% for using of PatBlt API instead of FillRect. (FillRect is a wrapper of PatBlt SelectObject'ing the specified Brush)
      - ~5% by preserving the memory bitmap (DoubleBuffer) for WM_PAINT and re-create only upon WM_SIZE.
    26-Apr-2020
    - Bugfix in the GetClipboardText function in Common.bas.
    19-Apr-2020
    - Internal improvement in VBFlexGridBase.bas.
    15-Apr-2020
    - Modified OLEGuids.tlb as following: (compiled with same uuid)
      - included hWnd param for IOleInPlaceActiveObjectVB and IOleControlVB
      Unregister to old OLEGuids.tlb is not necessary, just overwrite the file.
    - Returning a zero KeyChar in the EditKeyPress event will not cause anymore a beep. (like in a TextBox control)
    09-Apr-2020
    - Bugfix in the CellPicture property. It now returns as 'IPictureDisp' instead of 'IPicture'.
    07-Apr-2020
    - Major internal improvement as no WM_MOUSEACTIVATE overhead necessary anymore.
      This results for 'FlexTopParentValidateControls' being obselete and was removed!
    31-Mar-2020
    - Bugfix in the internal MoveNextRow and MoveNextCol function.
    22-Mar-2020
    - Bugfix in the CreateGDIFontFromOLEFont function. (Common.bas)
    24-Feb-2020
    - Bugfix in the ShowLabelTips property that it didn't show on fixed cells.
    06-Feb-2020
    - Improvement (cosmetic, not a bug) in VTableHandle.bas so that IOleControl do not disturb anymore in IDE on debugging.
      This affects only the Std-EXE version (not OCX) and only when setting breakpoints. (F9, F8 etc.)
    05-Jan-2020
    - Improvement in VTableHandle.bas as IPerPropertyBrowsing must NOT be subclassed anymore.
      No VTable remains subclassed, therefore VTableSubclass.cls got obselete and was removed!
    - Modified OLEGuids.tlb as following: (compiled with same uuid)
      - bugfix interface IPerPropertyBrowsing.
      Unregister to old OLEGuids.tlb is not necessary, just overwrite the file.
    03-Jan-2020
    - Improvement in VTableHandle.bas as IOleControl must NOT be subclassed anymore.
      It is necessary to replace also all controls. (.ctl)
    23-Dec-2019
    - Major performance boost for the 'DataSource' property. (ADO's GetRows method now used)
    09-Oct-2019
    - Change of how to achieve DPI-awareness to the controls for non-integral DPI.
      It's just a better technique now which reduces the number of resizes.
      However, the change has no visible impact for the end-user.
    19-Aug-2019
    - Minor internal improvement for ValidateEdit behavior.
    27-Jul-2019
    - Included the DirectionAfterReturn property. It allows to move the position of the current cell when the user presses return (Enter) key.
      This property works in conjunction with the WrapCellBehavior property. (like the TabBehavior property does)
    16-Jul-2019
    - Included the WantReturn property. Indicates when the user presses RETURN to perform the default button or to allow the flex grid to handle the return key.
      But it applies only when there is any default button on the form.
    17-Jun-2019
    - Included the ColFormat run-time property.
    - Included additional FlexEditReasonBackSpace enum const. Pressing the backspace key then starts cell editing and removes all content.
    14-Jun-2019
    - Included additional PictureAlignment enum constants to allow pictures to not overlap with the text.
    03-Jun-2019
    - If drop-down list extends beyond bottom edge of the screen (MonitorFromWindow API) then it will be displayed above the edit window.
      Just like a normal ComboBox would behave.
    
    [...]
    
    14-Jun-2017
    - First release.
    Name:  VBFlexGridDemo.jpg
Views: 788
Size:  91.5 KB
    Attached Files Attached Files
    Last edited by Krool; Yesterday at 04:32 AM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    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.
    - ShowInfoTips, ShowLabelTips and CellToolTipText 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.
    - 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.
    - 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 and related AutoClipboard property.
    - 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.
    - 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 many 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.
    Last edited by Krool; Jan 28th, 2023 at 05:26 AM.

  3. #3
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    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.
    QQ: 289778005

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by ChenLin View Post
    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.

  5. #5
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    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.
    QQ: 289778005

  6. #6
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    2,941

    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!!!!!!!

    regards
    Chris

  7. #7
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    2 questions:
    Are you going to implement data binding?
    How would you implement a virtual/on demand data source?

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by DEXWERX View Post
    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)
    Last edited by Krool; Jun 20th, 2017 at 04:29 PM.

  9. #9
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,481

    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.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Arnoutdv View Post
    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)

  11. #11
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    2,941

    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..

    Code:
     VBFlexGrid1.FlexFillFromRs(myADORecordset)
    just an Idea

    regards
    Chris

  12. #12
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,484

    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

  13. #13
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    2,941

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    I would have downloaded it before the ink on your OP had dried
    I agree;-))

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Bobbles View Post
    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.

  15. #15
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    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.

  16. #16
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,350

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by DEXWERX View Post
    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"):

    Code:
    [
      odl,
      uuid(8E203240-537D-11D3-BD8C-000000000000),
      dual,
      oleautomation
    ]
    interface IVSFlexDataSource : IUnknown {
        [id(0x00000001)]
        HRESULT GetFieldCount([out, retval] long* pFields);
        [id(0x00000002)]
        HRESULT GetRecordCount([out, retval] long* pRecords);
        [id(0x00000003)]
        HRESULT GetFieldName(
                        [in] long Field, 
                        [out, retval] BSTR* pFieldName);
        [id(0x00000004)]
        HRESULT GetData(
                        [in] long Field, 
                        [in] long Record, 
                        [out, retval] BSTR* pData);
        [id(0x00000005)]
        HRESULT SetData(
                        [in] long Field, 
                        [in] long Record, 
                        [in] BSTR newData);
    };
    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)...

    Olaf

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Schmidt View Post
    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"):

    Code:
    [
      odl,
      uuid(8E203240-537D-11D3-BD8C-000000000000),
      dual,
      oleautomation
    ]
    interface IVSFlexDataSource : IUnknown {
        [id(0x00000001)]
        HRESULT GetFieldCount([out, retval] long* pFields);
        [id(0x00000002)]
        HRESULT GetRecordCount([out, retval] long* pRecords);
        [id(0x00000003)]
        HRESULT GetFieldName(
                        [in] long Field, 
                        [out, retval] BSTR* pFieldName);
        [id(0x00000004)]
        HRESULT GetData(
                        [in] long Field, 
                        [in] long Record, 
                        [out, retval] BSTR* pData);
        [id(0x00000005)]
        HRESULT SetData(
                        [in] long Field, 
                        [in] long Record, 
                        [in] BSTR newData);
    };
    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.

  18. #18
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,350

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    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).

    Olaf

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Schmidt View Post
    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?

  20. #20
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    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.

  21. #21

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by DEXWERX View Post
    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.
    And the same for a Sort?

  22. #22
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,350

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    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).

    Olaf

  23. #23

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Schmidt View Post
    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)

  24. #24
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    That works, and is in line with how MS handled mshflxgd also.

  25. #25

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    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?

  26. #26
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    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)

  27. #27
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,350

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    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).

    Olaf

  28. #28

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    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.

  29. #29
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    This OLEGuids.tlb is 32 and cannot be referenced in win10 64.
    QQ: 289778005

  30. #30

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by ChenLin View Post
    This OLEGuids.tlb is 32 and cannot be referenced in win10 64.
    Did you put the OLEGuids.tlb in the SysWOW64 system folder?
    Also try to reference the file with Browse..

  31. #31
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    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".
    QQ: 289778005

  32. #32

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by ChenLin View Post
    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.
    Last edited by Krool; Jul 24th, 2017 at 12:17 AM.

  33. #33
    Addicted Member
    Join Date
    Feb 2014
    Posts
    254

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Actually, I also have problem registering OLEGuids.tlb on Win10 x64.

    Name:  OLEGuids.jpg
Views: 23971
Size:  40.6 KB

  34. #34

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Regsvr32 is wrong. Just let VB register it.
    There is a also a tool for registeeing type libs (and unregister)
    http://www.vbaccelerator.com/home/VB...y/article.html

  35. #35
    Addicted Member
    Join Date
    Feb 2014
    Posts
    254

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Oh, I did not know VB can register it. I just tried and it works.

    I also use CCRP Reg Util to register tlb (it has a choice for tlb) and it works on Win7 but not on Win10.

  36. #36

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,063

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by chosk View Post
    Oh, I did not know VB can register it. I just tried and it works.
    Glad to hear. Does the vbAccelerator tool also work?

  37. #37
    Addicted Member
    Join Date
    Feb 2014
    Posts
    254

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    The vbAccelerator tool... I tried download on 2 computers but file is invalid.

  38. #38
    Addicted Member
    Join Date
    Feb 2014
    Posts
    254

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    I found it in my backup. I have forgotten I downloaded perhaps years back.

    It can register but unregister gives a 8002801C error.

  39. #39
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    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.
    QQ: 289778005

  40. #40
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by chosk View Post
    Actually, I also have problem registering OLEGuids.tlb on Win10 x64.

    Name:  OLEGuids.jpg
Views: 23971
Size:  40.6 KB
    Try my way: use this TLB to override the TLB in the system
    QQ: 289778005

Page 1 of 20 123411 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width