dcsimg
Page 1 of 6 1234 ... LastLast
Results 1 to 40 of 206

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

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

    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".
    - In order to trap error raises via "On Error Goto ..." or "On Error Resume Next" it is necessary to have "Break on Unhandled Errors" selected instead of "Break in Class Module" on Tools -> Options... -> General -> Error Trapping.

    List of revisions:
    Code:
    09-Nov-2018
    - Internal improvement concerning design-mode handling.
    26-Oct-2018
    - Bugfix related to 25-Oct-2018 update.
    - Minor internal improvements.
    25-Oct-2018
    - Internal improvement concerning divider drag of the last row or col.
    09-Oct-2018
    - WM_SYSKEYDOWN/WM_SYSKEYUP considered now for KeyDown/KeyUp events.
    04-Oct-2018
    - RowID/RowIndex property included. The usage is similar to the ColKey/ColIndex property.
      RowIndex returns a row given its ID, whereas RowID returns/sets the ID given its row.
    27-Sep-2018
    - Included the SingleLine property.
    12-Sep-2018
    - Included optional argument Direction in the FindItem function. Also FindItem cannot be used anymore on a fixed row.
    11-Sep-2018
    - Included the FlexDataSource property (run-time only) to set a custom data source which fetches data from the IVBFlexDataSource interface.
      It comes along with several limitations (e.g. cannot use .Sort) and the behavior/definitions are similar to the IVSFlexDataSource from VSFlexGrid.
    - Included the DataRefresh method which forces the control to re-fetch all data from its data source. (and/or custom data source)
    - Included optional argument Wrap in the FindItem function.
    - The AddItem method now respects the ClipMode property setting.
    04-Sep-2018
    - Included optional argument ExcludeHidden in the FindItem function.
    - Added WS_EX_TRANSPARENT for the internal tooltip control which solved two issues:
      - The control did not receive focus when clicking on a tip from another control.
      - In Win10 the mouse wheel will scroll even if the mouse hovers over a tip. (in-place tip)
    03-Sep-2018
    - Bugfix in the Cell property for FlexCellSort setting.
    27-Aug-2018
    - Further optimization of the internal GetHitTestInfo function.
    26-Aug-2018
    - Major performance boost for internal GetHitTestInfo function.
    12-Aug-2018
    - TEXTMETRIC structure was declared as ANSI. Fixed to WIDE version.
      Unicode did not lack due to this bug, but it was a memory risk as WIDE version is larger than ANSI.
    28-Jul-2018
    - Internal GDI leak fixed. (forgot to restore old font handle in a hDCScreen)
    09-Jul-2018
    - Bugfix in the WrapCellBehavior property. Bug only affected when SelectionMode was ByRow or ByColumn.
    02-May-2018
    - Renamed enum 'FlexClipModeIncludeHidden' to 'FlexClipModeNormal'.
    - Included optional argument ExcludeHidden in the AutoSize method.
    22-Apr-2018
    - Included the ClipMode property that controls whether to include or exclude hidden cells in a clip command.
    20-Apr-2018
    - Internal bugfix in page scroll up and down in relation to zero width rows.
    - WM_LBUTTONDOWN intercepted (no MouseDown event) in case of divider row/col dragging.
      This is the same behavior as in the original MS(H)FlexGrid.
    16-Apr-2018
    - Bugfix in the CellFontName property, related to update on 05-Dec-2017. (This bug had only effect when FillStyle is set to FlexFillStyleRepeat)
    14-Mar-2018
    - Optimized the divider row/col dragging.
    - Included the HitRowDivider/HitColDivider property which returns the divider row/col from the last invoked .HitTest.
      The divider row/col contains already the necessary offset for FlexHitResultDividerRowTop and FlexHitResultDividerColumnLeft.
      In addition the offset includes hidden rows/cols. (zero width rows/cols are not offset to preserve MSFlexGrid compatibility)
    13-Mar-2018
    - Included the DividerDblClick event.
    09-Mar-2018
    - Bugfix related to custom sorting bugfix on 08-Mar-2018.
    08-Mar-2018
    - Critical bugfix for custom sorting. (FlexSortCustom)
    - Included enum FlexSortCurrencyAscending/FlexSortCurrencyDescending and FlexSortDateAscending/FlexSortDateDescending in Sort/ColSort property.
    04-Mar-2018
    - Bugfix in VTableHandle.bas related to 25-Feb-2018 update. (concerns unload stability in IDE only)
    25-Feb-2018
    - Major internal improvement in the VTableHandle.bas concerning IOleInPlaceActiveObject.
    20-Feb-2018
    - Unicode support when generating ASCII key combos, e.g. ALT + 3333.
    11-Feb-2018
    - Included the AutoSize method.
    23-Jan-2018
    - Included the TextWidth/TextHeight function that calculates for the current or an arbitrary cell the width and height length.
      For multiline text the heights are cumulated and for the width the line with the greatest width is taken. Similar to VB.Form's TextWidth function.
    21-Dec-2017
    - Improved the WM_MOUSEWHEEL handler for fine-grained wheel changes.
    09-Dec-2017
    - Improved VTableHandle.bas so it does not crash anymore when using VBCCRxx.OCX and VBFLXGRDxx.OCX in paralell. (concerns ActiveX control only)
    05-Dec-2017
    - Major performance fix. (Caused by update on 23-Nov-2017)
    - Bugfix in the CellFontName property.
      A change will now overwrite the CellFontCharset settings.
    23-Nov-2017
    - Final tweak to run in the VBA environment. (meaningful for OCX only)
    22-Nov-2017
    - Minor internal improvements.
    18-Nov-2017
    - Bugfix for generic sorting.
    27-Oct-2017
    - Again minor tweaks to run better in the VBA environment. (meaningful for OCX only)
    20-Oct-2017
    - Minor tweaks to run better in the VBA environment. (meaningful for OCX only)
    26-Sep-2017
    - Included the BeforeMouseDown event.
      The event is identical as in the MouseDown event, but an additional Cancel parameter allows you to prevent the default processing.
    22-Sep-2017
    - Minor bugfix in the internal GetHitTestInfo function.
    19-Sep-2017
    - Included the FormatString property.
    - Bugfix that the FixedAlignment returned not the ColAlignment when not preset.
    - FixedAlignment accepts now a value of -1 so that it is not preset anymore.
    17-Sep-2017
    - The Rows/Cols property can now be set lower or equal to the FixedRows/FixedCols property without raising an error.
      Like in the MS(H)FlexGrid the FixedRows/FixedCols property will be adjusted then accordingly.
    02-Sep-2017
    - The Font property is not written to the property bag anymore when it equals to Ambient.Font.
      Included new function OLEFontIsEqual in Common.bas.
    01-Sep-2017
    - Included the ClipSeparators property which enables to define two custom distinct characters to be used in clip strings.
    26-Aug-2017
    - Alpha (32bpp) icons in 'CellPicture' now drawn correctly per DrawIconEx instead of Picture.Render.
    07-Aug-2017
    - The HelpContextID and WhatsThisHelpID property is now also available when setting to a shadow object. ('Set' command)
    27-Jul-2017
    - Internal "DPI Aware" improvements.
      Improved the functions PixelsPerDIP_X/PixelsPerDIP_Y in Common.bas.
    25-Jul-2017
    - Pixels in the property bag are now treated as DIPs. (Device-independent pixels)
      There is no compatibility break in the property bag when there were saved at 100% (96) DPI.
      Included new functions PixelsPerDIP_X/PixelsPerDIP_Y in Common.bas.
      This "DPI Aware" enhancement affects the RowHeightMin/RowHeightMax and ColWidthMin/ColWidthMax property.
    24-Jul-2017
    - Included the EllipsisFormatFixed property which enables the setting to be differentiated between fixed and non-fixed cells.
    23-Jul-2017
    - Included the DataSource/DataMember property which allows to bind an Adodc control, DateEnvironment designer or ADODB.Recordset object.
      A reference to the msdatsrc.tlb (pre-installed since Win2k) is required.
      The new conditional compiliation constant 'ImplementDataSource' controls if the new feature is turned on.
      If turned off the 'DataBindingBehavior' might be changed back from 'vbComplexBound' to 'vbNone'.
    13-Jul-2017
    - Major internal improvement in the VTableHandle.bas
      It is necessary to replace also the control. (.ctl)
      Improvement is that no workaround is necessary anymore when the control is embedded into another UserControl.
    21-Jun-2017
    - Included the Cell property which allows to get or set cell settings directly for an arbitrary cell or range of cells without selecting them.
    14-Jun-2017
    - First release.
    Name:  VBFlexGridDemo.jpg
Views: 4665
Size:  94.4 KB
    Attached Files Attached Files
    Last edited by Krool; Nov 9th, 2018 at 04:23 PM.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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)
    - 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.
    - AllowSelection property included.
    - TabBehavior property included.
    - WrapCellBehavior property included.
    - ClipSeparators property included.
    - ClipMode property included to include (default) or exclude hidden cells in 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)
    - 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.
    - ColWidthMin property included. (analogous to the RowHeightMin property)
    - RowHeightMax/ColWidthMax property included.
    - 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 and FixedRowsVisible/FixedColsVisible 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)
    - 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.
    - 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 event included.
    - BeforeRowColChange/BeforeSelChange event included.
    - 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.
    - CurrencyAscending/CurrencyDescending and DateAscending/DateDescending enum included in the Sort/ColSort property.
    - AutoSize method included.
    - DividerDblClick event included.
    - DataRefresh method included.
    - FlexDataSource property (run-time only) included to set a custom data source via the IVBFlexDataSource interface.
    - Some other minor improvements.
    List of incompatibilities in relation to the MSFlexGrid control:
    Code:
    - FontWidth and CellFontWidth property not implemented.
    - Fixed cell(s) without cell(s). (e.g. FixedRows = 1 and Rows = 1)
    Last edited by Krool; Oct 4th, 2018 at 02:51 PM.

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

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    132

    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
    Frenzied Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    1,368

    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,102

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    Join Date
    Oct 2013
    Posts
    3,215

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    Frenzied Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    1,368

    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
    Posts
    1,138

    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
    Frenzied Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    1,368

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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,102

    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
    3,834

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    3,834

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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,102

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    3,834

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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,102

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

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

  25. #25

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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,102

    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
    3,834

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    132

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    132

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    252

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

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

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

  34. #34

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    252

    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
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,098

    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
    252

    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
    252

    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
    132

    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
    132

    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: 4771
Size:  40.6 KB
    Try my way: use this TLB to override the TLB in the system
    QQ: 289778005

Page 1 of 6 1234 ... 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
  •  



Featured


Click Here to Expand Forum to Full Width