Results 1 to 40 of 1350

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

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

    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:
    11-Apr-2024
    - Return key will be forwarded according to DirectionAfterReturn property after editing. (like as the TabBehavior property)
    29-Mar-2024
    - Included the MimicTextBox and ColMimicTextBox/ColMimicTextBoxFixed property. (Defaults to False)
      DT_EDITCONTROL will mimic the text-displaying characteristics of a multiline text box. This includes to break on characters instead on words.
      This is only meaningful if the word wrap property is set to true.
      The main benefit is to have no drawing difference anymore when editing a cell.
    11-Mar-2024
    - Included the LookupConv function which returns a converted lookup string of the current or a specified column.
      Use either FlexLookupConvValue or FlexLookupConvKey. (new enum)
    18-Feb-2024
    - Included the DragRow/DragCol function used to rearrange rows/cols by dragging the specified row/col with the mouse to a new position.
      To note is that this is NOT an OLE drag/drop operation and the function will enter a modal message loop to just return the new moved position.
      Example code: .RowPosition(i) = .DragRow(i)
      The demo project is updated to use this new function.
    - Combo list locked (not clickable) when it has no items.
      This avoids release of mouse capture when clicking inside a no items drop-down list. Just like a ComboBox does.
    09-Feb-2024
    - Included enum FlexDirectionAfterReturnEdit/FlexEditReasonReturn.
      By this the edit mode is initiated by the return key, but only when shift state is 0.
      It is intentionality included in the DirectionAfterReturn property to not
      change default behavior and it's logical because you can either move the cursor or start edit mode, but not both.
    02-Feb-2024
    - Space/BackSpace key now only invoke cell editing when shift state is 0.
    - Space key now only invoke cell checkbox check when shift state is 0.
    30-Jan-2024
    - Included the OLEDragDropScrollOrientation property which can be 0 - Horizontal, 1 - Vertical or 2 - Both (default).
    - Included the IncrementalSearch event.
    - WM_CANCELMODE will now cancel the incremental search, if applicable.
    29-Jan-2024
    - Included the CanPaste function. The Paste method pastes only when there is a text format available in the clipboard.
    - Included the IncrementalSearchTime run-time property.
    - Included the AllowDropFiles property and DropFiles event.
    24-Jan-2024
    - Label tips now updated to cell font over which it is displayed to have an perfect overlay.
      Info and scroll tips remain on the standard default font of the tool tip.
    23-Jan-2024
    - FlexClearText for the .Clear method can now be used even when a custom data source is set.
    - Added FlexClearClip enum (clip range) which the .Delete method now uses instead of FlexClearSelection.
    - Added FlexClipPasteModeExtended/FlexClipPasteModeExtendedAutoSelection enum.
      If ClipPasteMode is >= Extended then FlexClearClip deletes also the extended selection. (opposite action)
    11-Jan-2024
    - ReaderMode shows now a half blended cursor image indicating the anchor position. (like in WordPad)
    10-Jan-2024
    - Included the AllowReaderMode property. (auto-scrolling and panning)
      It defaults to False, when set to True it uses the DoReaderMode API upon WM_MBUTTONDOWN.
    09-Jan-2024
    - WM_MOUSEHWHEEL support. (horizontal mouse wheel)
    30-Dec-2023
    - Const VARIANT_CB now 24 instead of 16 for Win64.
    12-Dec-2023
    - Included the ColCheckBoxesHitTestInvisible/ColCheckBoxesHitTestInvisibleFixed run-time property.
      It determines whether check boxes are visible but not hit-testable. (cannot interact with mouse cursor)
      This can be useful for representation only check boxes (e.g. FlexTextAsCheckBox) where hot-light is not needed and CellClick (etc.) events should fire.
      However, this does not avoid changing the checked state by space key.
      To avoid that use the FlexDisabled* checked states or set Cancel = True on the CellBeforeCheck event.
    09-Dec-2023
    - Fixed that no invalidation occurs when setting Rows/Cols to 0. (regression 13-Nov-2023)
    - Included the ClearRowInfo/ClearColInfo method which clears the info structure for the specified row/column.
      An index of -1 will clear the info structure for all rows/columns.
    02-Dec-2023
    - Included the SelectAll method which is useful to call for providing a Ctrl + A feature within the KeyDown event.
    14-Nov-2023
    - Added enum 4 - Extended for the ClipCopyMode property. (and 5,6,7 for Fixed* variants)
      This is useful for FreeByRow, FreeByColumn selection mode or for AllowMultiSelection.
      The extended clip copy mode contains the visual selection and not the technical single selection.
    13-Nov-2023
    - No crash anymore in internal AddSelectedRows/RemoveSelectedRows when grid is empty. (AllowMultiSelection property)
    - No illogical Row/Col combination (e.g. -1/0) possible anymore when grid is empty. (Rows = 0 or Cols = 0)
      Such combination could occur when changing for example FixedRows and Rows is > 0 but Cols still 0.
    07-Nov-2023
    - Included the ComboButtonNonClientWidth/ComboButtonNonClientHeight property.
    - Exposed the GetGridLineOffsets method which retrieves the grid line offsets between cells. (optional row/col subscripts)
      The internal method got renamed to GetGridLineOffsetsStruct.
    03-Nov-2023
    - Edge case bugfix in the CopyFromRecordset function and minor tweaks.
    02-Nov-2023
    - Included the CopyFromRecordset function which copies the contents of an ADO or DAO Recordset onto the flex grid.
      It works like the Excel function which returns the number of fetched records and copies from the current position to EOF.
      The number of maximum rows and columns can be specified.
      If omitted it is maximum remaining rows and columns that the grid can receive relative to the destination starting point.
      The grid will not grow and it just ignores the overflow of rows and columns. (like Excel)
      The destination row/col can be specified where the pasting onto the flex grid starts.
      If omitted it is the first non-fixed row and first non-fixed column.
    30-Oct-2023
    - Divider resize drag will not be applied anymore when the divider drag never moved. (like MS(H)FlexGrid)
      This solves also the problem with FlexRowSizingModeUniform and double click divider to auto size.
    28-Oct-2023
    - Changing SelectionMode property does not reset selection anymore. (like MS(H)FlexGrid)
      However, at design-time it still does change and reset the selection.
    26-Oct-2023
    - Included the InsertMark/InsertMarkMode run-time property.
      The InsertMarkMode can be set to 0 - ByRow (default) or 1 - ByColumn.
    - Included the HitTestInsertMark function which returns the insert mark row or column.
    - Included the InsertMarkColor property.
    25-Oct-2023
    - Included the DropHighlight/DropHighlightMode run-time property.
      The DropHighlightMode can be set to 0 - ByRow (default) or 1 - ByColumn.
    24-Oct-2023
    - Internal DrawCellCheckBox function now clipped to the cell rect boundaries.
    - Included the OLEDragDropScroll property which defaults to True.
    23-Oct-2023
    - Internal GetBestWidth/GetBestHeight doesn't measure anymore hidden text.
      Text can become hidden by FlexTextAsCheckBox or by an image list.
    - Added enum FlexCellTextHidden for the Cell property. (read-only)
    - Added enum FlexCellHasCustomFormatting/FlexCellHasTag for the Cell property.
      It returns True if memory is allocated. Set to False to release the memory or True to force allocation.
    22-Oct-2023
    - Included the ColImageList As Variant property. (like in vsFlexGrid)
      Either an ImageList object or an hImageList handle can be set. (vsFlexGrid allows only handle)
      Numeric text will be treated as an image index. (both, object or handle)
      Otherwise it will be tried to access the image index by it's key. (object only)
      The image alignment is based on the text alignment. (CellAlignment/ColAlignment/FixedAlignment)
      The cell text will become hidden if an image got drawn.
    - Included the CellImageCallback event where the app can provide the image value.
      The Handled parameter must be set to True to overwrite the default behavior.
      It enables also a way to ensure that no image will be tried to retrieve for certain cells. (e.g. for fixed rows)
    20-Oct-2023
    - Included enum FlexAlignmentGeneralTop/FlexAlignmentGeneralCenter/FlexAlignmentGeneralBottom.
      The enum FlexAlignmentGeneral keeps valid and is the default column alignment value.
    19-Oct-2023
    - Included the CellTag property which holds a variant to store any extra data.
      The variant is allocated only when needed to keep memory usage low.
    - Included enum FlexClearTag for the .Clear method.
    - Included enum FlexCellTag for the .Cell property.
    09-Oct-2023
    - Bugfix for CellLeft/ClientLeft and WS_EX_LAYOUTRTL. (Container vs. Control)
    05-Oct-2023
    - Changing TopRow/LeftCol by app code now works even when there are no scrollbars. (like in vsFlexGrid)
      It can be considered a mis-behavior in the MS(H)FlexGrid that this is not possible.
      This allows to sync column scroll to a footer style grid that has no scrollbars.
    04-Oct-2023
    - Included the ColWordWrapOption/ColWordWrapOptionFixed run-time property.
      This allows to change per column of how text is displayed. Like in the MSHFlexGrid.
      Enum FlexWordWrapOptions: 0 - None (default), 1 - WordBreak, 2 - SingleLine and more..
    02-Oct-2023
    - Included the ClientLeft/ClientTop and ClientWidth/ClientHeight read-only/run-time property.
    01-Oct-2023
    - Linefeed character (Ctrl+Enter) now allowed for incremental searches.
    - Backspace character now allowed for incremental searches.
      It undoes the last typed letter. Continuing to hit the backspace key takes you back farther.
    - 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)
    
    [...]
    
    14-Jun-2017
    - First release.
    Name:  VBFlexGridDemo.jpg
Views: 1355
Size:  93.6 KB
    Attached Files Attached Files
    Last edited by Krool; Apr 12th, 2024 at 12:23 PM.

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