-
Feb 28th, 2024, 03:24 AM
#1281
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Calcu
It's possible to autoadjust the width of the column "before" selecting anyhing ?
Yes, you may use the ColWidth property and the TextWidth function in the ComboBeforeDropDown or ComboCloseUp events.

Edited:
The code below is edited in accordance with the post #1283 by Krool.
Code:
Const COL_COMBO = 1
Private nOldColWidth As Long, bColWidthIsChanged As Boolean
Private Sub Command3_Click()
With VBFlexGrid1
.ColComboCue(COL_COMBO) = FlexComboCueDropDown
.ColComboMode(COL_COMBO) = FlexComboModeDropDown
.ColComboItems(COL_COMBO) = "Arnold|Bob|Charlie|David"
End With
End Sub
Private Sub VBFlexGrid1_ComboBeforeDropDown( _
ByVal Reason As VBFLXGRD17.FlexComboDropDownReasonConstants, _
Cancel As Boolean)
Dim nTextWidth As Long, nNewTextWidth As Long
Dim aComboItems As Variant, i As Long
With VBFlexGrid1
If (.EditCol = COL_COMBO) And (LenB(.ColComboItems(COL_COMBO))) Then
aComboItems = Split(.ColComboItems(COL_COMBO), "|")
For i = LBound(aComboItems) To UBound(aComboItems)
nNewTextWidth = .TextWidth(aComboItems(i), .EditRow, .EditCol)
If nTextWidth < nNewTextWidth Then nTextWidth = nNewTextWidth
Next
nOldColWidth = .ColWidth(COL_COMBO)
.ColWidth(COL_COMBO) = nTextWidth \ 15 * 15
bColWidthIsChanged = True
End If
End With
End Sub
Private Sub VBFlexGrid1_ComboCloseUp()
If bColWidthIsChanged Then
VBFlexGrid1.ColWidth(COL_COMBO) = nOldColWidth
bColWidthIsChanged = False
End If
End Sub
Last edited by Nouyana; Feb 28th, 2024 at 08:58 AM.
Reason: Code improvements
-
Feb 28th, 2024, 04:26 AM
#1282
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
But this way the combo with is not changing before opening it, isn't it?
Add another item at the combo, for example: 'this is a long entry for combo'
can you see the entire item when you open the combo ?
Last edited by Calcu; Feb 28th, 2024 at 04:31 AM.
-
Feb 28th, 2024, 05:09 AM
#1283
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Nouyana
The only problem is how to identify current drop-down column. In the code below I use the Col property (If .Col = COL_COMBO Then ... ), but this is a bad idea.
Instead of .Col use the .EditCol property. So just apply .EditRow and .EditCol into the .TextWidth function. Thanks for your assistance.
-
Feb 28th, 2024, 09:02 AM
#1284
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Calcu
But this way the combo width is not changing before opening it, isn't it?
Yes.
 Originally Posted by Calcu
Add another item at the combo, for example: 'this is a long entry for combo'
can you see the entire item when you open the combo ?
No. Maybe Krool can improve it.
-
Feb 28th, 2024, 11:23 AM
#1285
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
You can also enlarge the drop-down list upon EditSetupWindow event via SetWindowPos (pass SWP_NOMOVE SWP_NOACTIVATE etc.)
Then you see the item while list is dropped down. After the edit you may run an .AutoSize.
-
Mar 1st, 2024, 04:20 AM
#1286
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi Krool,
I noticed that clicking the scrollbar of a grid doesn't set the focus to it, and thus doesn't trigger a lost focus event on a control that was selected before. Is this by design or a bug?
Regards,
Erwin
-
Mar 1st, 2024, 08:49 AM
#1287
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Erwin69
Hi Krool,
I noticed that clicking the scrollbar of a grid doesn't set the focus to it, and thus doesn't trigger a lost focus event on a control that was selected before. Is this by design or a bug?
Regards,
Erwin
That's by design. Why it should be different?
-
Mar 1st, 2024, 01:00 PM
#1288
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thanks for the answers!
Will try the editsetupWindow.
Another question, what way is faster to find "a lot of items"? :-)
Let me explain.
I have 2 grids, one has 38566 rows, the other one 14957.
i want to cross information between them, just check if one value exists on the other grid (in both ways).
Actually i'm using:
Code:
For Linea = 1 To GR1.Rows - 1
Linea2 = GR2.FindItem(GR1.TextMatrix(Linea, GR1.ColIndex("codifica")), 1, GR2.ColIndex("referencia"), FlexFindMatchExact, False, True, False, FlexFindDirectionDown)
If Linea2 >= 1 Then
GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = GR2.TextMatrix(Linea2, GR2.ColIndex("costesumado"))
Else
GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = 0
End If
DoEvents
Next Linea
it's working fine, but slow, the cells checked are text cells.
I sorted the results first, in order to be faster, but is still slow.
Any idea how to do this faster ?
-
Mar 1st, 2024, 01:52 PM
#1289
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Calcu
Thanks for the answers!
Will try the editsetupWindow.
Another question, what way is faster to find "a lot of items"? :-)
Let me explain.
I have 2 grids, one has 38566 rows, the other one 14957.
i want to cross information between them, just check if one value exists on the other grid (in both ways).
Actually i'm using:
Code:
For Linea = 1 To GR1.Rows - 1
Linea2 = GR2.FindItem(GR1.TextMatrix(Linea, GR1.ColIndex("codifica")), 1, GR2.ColIndex("referencia"), FlexFindMatchExact, False, True, False, FlexFindDirectionDown)
If Linea2 >= 1 Then
GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = GR2.TextMatrix(Linea2, GR2.ColIndex("costesumado"))
Else
GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = 0
End If
DoEvents
Next Linea
it's working fine, but slow, the cells checked are text cells.
I sorted the results first, in order to be faster, but is still slow.
Any idea how to do this faster ?
Safe the various .ColIndex() results in a variable before the loop.
-
Mar 2nd, 2024, 07:13 AM
#1290
New Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Krool
You can also enlarge the drop-down list upon EditSetupWindow event via SetWindowPos (pass SWP_NOMOVE SWP_NOACTIVATE etc.)
Then you see the item while list is dropped down. After the edit you may run an .AutoSize.
fethiye tours
Thanks for information
-
Mar 2nd, 2024, 03:57 PM
#1291
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Calcu
Any idea how to do this faster ?
1. Use If Linea2 > 0 instead of If Linea2 >= 1
2. Use If Linea mod 1000 = 0 Then DoEvents instead of just DoEvents
3. Use With GR1 for the whole loop
4. TextArray should be faster then TextMatrix
5. Without "End If" will be a bit faster (If Linea2 > 0 Then ... Else ...)
6. Use correct datatypes. I mean:
GR1.TextMatrix(...) = "0"
If Linea2 > 0& Then
etc.
7. Krool's advice
-
Mar 3rd, 2024, 03:34 AM
#1292
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thanks Nouyana !
Trying it.
-
Mar 3rd, 2024, 09:28 AM
#1293
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Calcu
it's working fine, but slow, the cells checked are text cells.
I sorted the results first, in order to be faster, but is still slow.
Any idea how to do this faster ?
If you really want to make it fly, you can use a fast, hash-based lookup-container (e.g. a Dictionary):
Code:
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare ' or vbBinaryCompare if case-sensitivity is needed
For Linea = 1 To GR2.Rows - 1 'pre-add the Key/Value-pairs into the Dictionary from Grid 2 in a pre-loop
.Add GR2.TextMatrix(Linea, GR2.ColIndex("referencia")), Linea
Next Linea
For Linea = 1 To GR1.Rows - 1
Linea2 = .Item(GR1.TextMatrix(Linea, GR1.ColIndex("codifica"))) 'superfast Lookup of Gr2-LineNrs via Gr1-Keys
If Linea2 >= 1 Then
GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = GR2.TextMatrix(Linea2, GR2.ColIndex("costesumado"))
Else
GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = 0
End If
Next Linea
End With
Krools advice with the pre-buffering of Col-Indexes still applies -
but the above might already be entirely sufficient, to achieve a significant speedup.
Olaf
-
Mar 4th, 2024, 08:52 AM
#1294
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thanks!
Trying it too, i was changing everything to work with temporal MySQL tables, because it seems they were faster, but I will try this too.
Last edited by Calcu; Mar 4th, 2024 at 08:59 AM.
-
Mar 4th, 2024, 03:12 PM
#1295
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
THANKS!
It's incredible fast!, i never used a dictionary... something new learned today!
thanks again
-
Mar 4th, 2024, 05:30 PM
#1296
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Public Function FlexFillFromRs(Rs As ADODB.Recordset, _
Flex As MSFlexGrid)
Can it bind the record machine of the database and support automatic updating?
like set datagrid1.datasource=recordset1
-
Mar 5th, 2024, 01:58 PM
#1297
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Krool
Included enum FlexDirectionAfterReturnEdit/FlexEditReasonReturn.
Krool, can you add an Excel-style return behaviour?
-
Mar 6th, 2024, 01:49 PM
#1298
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Krool
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.
Am I understand right that this equality is always correct?
ComboButtonWidth - ComboButtonClientWidth = ComboButtonNonClientWidth = ComboButtonNonClientHeight
-
Mar 6th, 2024, 02:26 PM
#1299
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Krool, can you somehow explain me where is the ClientWidth/Height, NonClientWidth/Height and GridLineOffsets here?
ComboButtonNonClientWidth = 90 (6px)
ComboButtonNonClientHeight = 90 (6px)
ComboButtonClientWidth = 195 (13px)
GetGridLineOffsets:
Left = 0
Top = 0
Right = 15 (1px)
Bottom = 15 (1px)

Code:
Private Sub Command1_Click()
Dim Picture As IPictureDisp
Dim nLeft&, nRight&, nTop&, nBottom As Long
With VBFlexGrid1
.Cell(FlexCellComboCue, 1, 1) = FlexComboCueButton
Debug.Print .ComboButtonNonClientWidth
Debug.Print .ComboButtonNonClientHeight
Debug.Print .ComboButtonClientWidth
Call .GetGridLineOffsets(nLeft, nTop, nRight, nBottom)
Debug.Print nLeft, nTop, nRight, nBottom
Set Picture1.Picture = LoadPicture(MY_ICON)
Set Picture = Picture1.Picture
Set .ColComboButtonPicture(1) = Picture
.ColComboButtonWidth(1) = .ComboButtonNonClientWidth + _
Me.ScaleX(Picture.Width, vbHimetric, vbTwips)
End With
End Sub
-
Mar 10th, 2024, 09:09 AM
#1300
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Nouyana
Am I understand right that this equality is always correct?
ComboButtonWidth - ComboButtonClientWidth = ComboButtonNonClientWidth = ComboButtonNonClientHeight
The below is correct:
ComboButtonWidth - ComboButtonClientWidth = ComboButtonNonClientWidth
However, NonClientWidth can in theory differ from the NonClientHeight. I have no control about the non-client metrics, it's MS.
-
Mar 10th, 2024, 11:58 AM
#1301
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by softv
Great, krool. Some weeks back, when I needed this requirement, I stumbled upon our great Olaf's solution ( cFlexSQLiteDS) here - https://www.vbforums.com/showthread....=1#post5514140 - it was very much for (y)our fabulous VBFlexGrid only. Olaf's readymade solution worked like a charm, as always. Its great now to see this functionality inbuilt in VBFlexGrid itself. I am yet to get time to download the latest VBFlexGrid and see what methodology you have adopted, to accomplish this 'CopyFromRecordSet' functionaltiy. The features you have specified for the CopyFromRecordSet function look wonderful. Thanks a TON. Looking forward to avail them soon, some time in the coming days.
Always remaining in gratitude to the wisdom of you, Olaf, LaVolpe, et al.
Kind Regards.
Dear Krool,
Today, I got time to check out the recently added functionality of "CopyFromRecordset". Thanks a TON!
Using dear Olaf's RC6, I could make it (CopyFromRecordset) to work when using it as follows. Hope this is the direct/shortest/fastest/right way, if I use "CopyFromRecordset" to fetch records from a SQLite database. If there is a better way, kindly let me know the same.
--
Set Rs = Cnn.OpenRecordset("Select * from Table1")
cnt =VBFlexGrid1.CopyFromRecordset(Rs.GetADORsFromContent)
--
I take this opportunity to once again thank you in TONS for all your splendid controls. God Bless you! God Bless all!
Kind Regards.
Love is God . God is Love
-
Mar 10th, 2024, 01:03 PM
#1302
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear Krool,
1. Is it possible to give a functionality by which I can display the ScrollTipText even when thumb is not moved manually but otherwise? (for instance, when user navigates down the list of rows using arrow keys). If this functionality is already available, kindly let me know how to achieve it.
2. Is it possible to include a property which says that ScrollEvent will be generated even when there are no more rows to show? And, when it is set to True, ScrollEvent should get generated when the scroll box's bottom or top arrow is clicked (even when there are no more rows to show). I just felt that this would further simplify one's task of automatic/dynamic loading of further records when there are no more records to show in the current set of records loaded in the grid.
Thanks a TON.
Kind Regards.
Love is God . God is Love
-
Mar 10th, 2024, 03:41 PM
#1303
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by softv
Using dear Olaf's RC6, I could make it (CopyFromRecordset) to work when using it as follows. Hope this is the direct/shortest/fastest/right way, if I use "CopyFromRecordset" to fetch records from a SQLite database. If there is a better way, kindly let me know the same.
Try to use the FlexDataSource property.
Example
-
Mar 10th, 2024, 05:25 PM
#1304
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Krool
That's by design. Why it should be different?
Well, I figured the scrollbar is part of the grid-control, hence there is change of focus from one control to the other. In my specific situation, the focus is on a textbox or combobox, which would have to be repositioned or made invisible when the user starts scrolling the grid.
It's not a showstopper for me, and there is probably a way to work around it, but I was just wondering.
-
Mar 11th, 2024, 12:38 AM
#1305
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Nouyana
Try to use the FlexDataSource property.
Example
Dear Nouyana,
Thanks a TON. I really do appreciate such immediate interest and an example program (that too, created afresh on 10-March-2024!!!) with header&inline documentations. Thank you so much for the interest shown. Really.
Initially, i could not run the project. But, I quickly realised that I need to download and give reference to Krool's VBSQLite12.Dll.
Since I am using RC6, I think I need to set Const RECORDSET_TYPE = "RC6" and use RC6.cGlobal. This part I will try later, when I get time. But, thank you once again for creating an example afresh, which it seems like you may update in the future##, as and when you get time.
(##) as you have given a release number of '0.2 aplha'
By the way, Krool, I was not aware of your sqlite wrapper at all, all these days. Thanks a TON for this contribution too, for the society.
Kind Regards.
Love is God . God is Love
-
Mar 11th, 2024, 12:45 AM
#1306
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear Krool,
A property like 'RowsVisible' has been extended to cover 'FlexVisibilityCompleteOnly' and FlexVisibilityPartialOK.
Based on properties like above, I have the following request. In case my request is incorrect (one way or the other) at the fundamental level itself, kindly bear with me and ignore my request.
--
I humbly feel that if 'Rows' property is extended to cover 'All', 'SansFixedFrozenHidden', 'SansFixed', 'SansFrozen', 'SansHidden', 'SansFixedFrozen', 'SansFixedHidden', 'SansFrozenHidden' and any other possibilities you can think of, that would be much helpful. Likewise, Cols property too, of course.
If extending Rows&Cols properties will mean that it will not be compatible with MSFlexGrid and hence cannot be done, then kindly consider having any other property (say 'RowsNeeded') which covers 'All', 'SansFixedFrozenHidden', 'SansFixed', 'SansFrozen', 'SansHidden', etc.
--
By the way, if I have missed any property or function which already provides information such as above straightforwardly, kindly bear with me and let me know the same.
Kind Regards.
Love is God . God is Love
-
Mar 11th, 2024, 03:35 AM
#1307
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Why do you need them? They are simple additions and subtractions of the current available properties
-
Mar 11th, 2024, 05:49 AM
#1308
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Arnoutdv
They are simple additions and subtractions of the current available properties
Yes. You are totally right, of course. But, as requested by me earlier, I felt that it would be "straightforward" if such info can be accessed directly as a "property" itself [preferably covered by .Rows() property itself] instead of by any other means and it is "part of Krool's control itself", by default. Personally, in my humble opinion, I felt that it makes it all easier and simpler for me since rows and cols info are accessed frequently by me and I use Krool's VBFlexGrid in more than one project of mine.
Kind Regards.
Love is God . God is Love
-
Mar 11th, 2024, 06:26 AM
#1309
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I use the vsFlexGrid and always use basic coding statements like:
Code:
For lRow = .FixedRows To .Rows - 1
'
NofActiveCols = .Cols - .FrozenCols - .FixedCols
-
Mar 11th, 2024, 02:53 PM
#1310
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Included the LookupConv function which returns a converted lookup string of the current or a specified column.
Use either FlexLookupConvValue or FlexLookupConvKey. (new enum)
If no conversion occured a vbNullString (StrPtr() = 0) is returned.
This can be helpful in a paste operation to convert to or from an associated value.
For edit input operation this back and forth lookup conversion is done automatically.
The OCX VBFLXGRD17 was also updated. The internal type lib version is now 1.7.
Code:
Object={2DA70529-3366-414A-B408-46083BCD481B}#1.7#0; VBFLXGRD17.OCX
-
Mar 11th, 2024, 03:12 PM
#1311
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Krool
Update released.
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.
I think this is a very unpredictable and memory-intensive function.
1. The first question is why don't you limit the number of rows for calling the SetCellText? You limit cols, but not rows:
Code:
If (Col + (UBoundCols - LBoundCols)) > (Cols - 1) Then UBoundCols = LBoundCols + (Cols - 1)
2. The second one. In my opinion the function should clean the previous inserted records after the last row of currently inserted records if the EOF is reached.
3. I would prefer the MoveNext method instead of GetRows because of low memory consumption.
4. I have not tested it, but i think you may get a type mismatch error here if the ArrRows will contain an object:
Code:
Call SetCellText((iRow + (0 - LBoundRows)) + Row, (iCol + (0 - LBoundCols)) + Col, (ArrRows(iCol, iRow)))
-
Mar 11th, 2024, 03:53 PM
#1312
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Nouyana
I think this is a very unpredictable and memory-intensive function.
1. The first question is why don't you limit the number of rows for calling the SetCellText? You limit cols, but not rows:
Code:
If (Col + (UBoundCols - LBoundCols)) > (Cols - 1) Then UBoundCols = LBoundCols + (Cols - 1)
2. The second one. In my opinion the function should clean the previous inserted records after the last row of currently inserted records if the EOF is reached.
3. I would prefer the MoveNext method instead of GetRows because of low memory consumption.
4. I have not tested it, but i think you may get a type mismatch error here if the ArrRows will contain an object:
Code:
Call SetCellText((iRow + (0 - LBoundRows)) + Row, (iCol + (0 - LBoundCols)) + Col, (ArrRows(iCol, iRow)))
1.
I don't need to limit UBoundRows because it's limited already in Data.GetRows(Rows). (If Rows > (PropRows - Row) Then Rows = PropRows - Row)
2.
My intention was to imitate excel in this regard and excel's CopyFromRecordset does also no cleanup. You may just call .Clear prior to .CopyFromRecordset.
And normally you re-adjust the number of rows to the .RecordCount of the recordset. Thus any left over will be cut off anyway.
3.
Yes maybe. But GetRows is faster as it fetches everything in one swoop.
4.
Yes could be. But what sense does it make to query for an object and feed a grid ? You may convert it in the query itself to a text format or so..
-
Mar 12th, 2024, 02:06 PM
#1313
Hyperactive Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Krool
3.
Yes maybe. But GetRows is faster as it fetches everything in one swoop.
Try to use the undocumented Collect property. It's 20% faster. Works with both - ADO and DAO. Or you may use GetRows getting by 10 rows step by step.
 Originally Posted by Krool
4.
Yes could be. But what sense does it make to query for an object and feed a grid ? You may convert it in the query itself to a text format or so..
You may don't now what is in the table. Maybe you just want to SELECT * FROM unknown_table. If it's an object then you can insert the "object" word. In the Excel nothing is inserted from fields with objects. But with no errors of course.
In addition, I think that cutting rows and cols should be optional. Say, you have an dbOpenForwardOnly DAO recordset (which consumes low memory) and therefore you cannot determine the number of records, but you want to get them all.
Ultimately, the CopyFromRecordset function only makes sense if it is more than just a wrapper for the GetRows method.
-
Mar 12th, 2024, 02:38 PM
#1314
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Nouyana
Try to use the undocumented Collect property. It's 20% faster. Works with both - ADO and DAO. Or you may use GetRows getting by 10 rows step by step.
You may don't now what is in the table. Maybe you just want to SELECT * FROM unknown_table. If it's an object then you can insert the "object" word. In the Excel nothing is inserted from fields with objects. But with no errors of course.
In addition, I think that cutting rows and cols should be optional. Say, you have an dbOpenForwardOnly DAO recordset (which consumes low memory) and therefore you cannot determine the number of records, but you want to get them all.
Ultimately, the CopyFromRecordset function only makes sense if it is more than just a wrapper for the GetRows method.
With the object you need to explain what exact datatype the problematic field has so to check for it.
Of course it should be improved in that regard.
With your dbOpenForwardOnly DAO is problematic.
Here you better do a .moveNext and .AddItem each time until .EOF.
Or alternatively you make first a SELECT COUNT(*) and then adjust the grid rows and then feed via CopyFromRecordset from your dbOpenForwardOnly DAO.
-
Mar 13th, 2024, 10:11 PM
#1315
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Arnoutdv
I use the vsFlexGrid and always use basic coding statements like:
Code:
For lRow = .FixedRows To .Rows - 1
'
NofActiveCols = .Cols - .FrozenCols - .FixedCols
Yes, I code in a similar manner.
However, I humbly felt, that calling .cols(Active) [and perhaps even .rows(Lower), .rows(Upper)] will not only make things easier for people like me but also improve code readability and understanding for people like me.
By .cols(Active), I mean something that would be equal to ".Cols - .FrozenCols - .FixedCols". Similarly, .rows(Upper) would mean ".rows - 1".
The thing is that existing code of mine, yours or anybody's can remain intact (and can continue to remain intact, if one wishes to) since calling .rows without parameters would always default to .rows(All), similar to how calling .RowsVisible without parameters defaults to .RowsVisible(FlexVisibilityCompleteOnly).
So, no harm in making .rows and .cols to cover extra parameters, was/is my personal humble feeling (Or, am I wrong? Will there be any issues?). If no issues, then, once such extra parameters are introduced, I feel that people like me can readily start availing them while those who do not wish to use them can continue to code as usual in their regular manner. So, Krool can give a thought for the extra parameters, I humbly felt, and hence placed that earlier request of mine.
The names of the parameters can always be suitably chosen by Krool, I thought. I just suggested Active, All, SansFixed, Lower, Upper, etc. That's all.
Kind Regards.
Last edited by softv; Mar 13th, 2024 at 11:31 PM.
Love is God . God is Love
-
Mar 15th, 2024, 12:08 AM
#1316
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear Krool,
For me, in ScrollTip event [ScrollTip(ByVal Row As Long, ByVal Col As Long)], the value of 'Col' is always -1. What mistake am I doing?
Note: For checking purpose, I set a value for .Col in the Scroll event. Then also, Col is always -1 in the ScrollTip event.
Just now I remembered that I can check the above in your demo too. So, I just now did the same. Only the Row value gets shown always in your demo. The Col value is never shown since in your code## you are showing the Col value only when Row is not greater than -1. So, what exactly is the role of Col value in the ScrollTip event? I am not able to understand clearly. Kindly let me know.
(##)
Private Sub VBFlexGrid1_ScrollTip(ByVal Row As Long, ByVal Col As Long)
If Row > -1 Then
VBFlexGrid1.ScrollTipText = "Row " & VBFlexGrid1.TextMatrix(Row, 0)
ElseIf Col > -1 Then
VBFlexGrid1.ScrollTipText = "Column " & VBFlexGrid1.TextMatrix(0, Col)
End If
End Sub
Kind Regards.
Last edited by softv; Mar 15th, 2024 at 12:15 AM.
Love is God . God is Love
-
Mar 15th, 2024, 12:13 AM
#1317
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by softv
Dear Krool,
For me, in ScrollTip event [ScrollTip(ByVal Row As Long, ByVal Col As Long)], the value of 'Col' is always -1. What mistake am I doing?
Note: For checking purpose, I set a value for .Col in the Scroll event. Then also, Col is always -1 in the ScrollTip event.
Just now I remembered that I can check the above in your demo too. So, I just now did the same. Only the Row value gets shown always in your demo. The Col value is never shown since its always -1 only and in your code## you are showing the Col value only when it is not -1. So, what should be done so that Col is not -1 in the ScrollTip event?
(##)
Kind Regards.
On vertical scroll the col is -1.
So just perform a horiz. Scroll. See demo.
-
Mar 15th, 2024, 12:18 AM
#1318
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thank you so much for your swift reply, Krool. Got it.
Kind Regards.
Note:
Even before I could see your reply, I had edited my original question, somewhat. Just informing you this. Nothing else. Because, your answer holds good of course even after I edited my question. I was not expecting "such a quick reply" from you! Thanks Krool, once again.
Last edited by softv; Mar 15th, 2024 at 12:39 AM.
Love is God . God is Love
-
Mar 15th, 2024, 12:26 AM
#1319
Addicted Member
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Dear Krool,
Now and then, I have read that VBFlexGrid can be used as a ListBox. Is it straightforward through some property or something like that? Or, have I to implement that functionality? If so, is there any readymade code snippet available which shows the ListBox implementation of VBFlexGrid? If so, kindly share.
Same way, if a readymade implementation of using VBFlexGrid as a ComboBox (incl. the 'Search' facility, as in a ComboBox) is available, kindly share the same. Will remain thankful.
If no readymade implementations available, I shall attempt them myself, of course, when time permits.
I take this opportunity to once again thank you for all your controls.
Kind Regards.
Love is God . God is Love
-
Mar 15th, 2024, 04:42 AM
#1320
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by PietroV
Krool,
I have debugged going through the source code of the OCX and noted that for some reason the problem is caused by a TinyInt field:
although the ADODB recordset can handle the field correctly the ADODB Recordset.Getrows() function used to fill the ArrRows array fails to convert it correctly and create the problem.
Converting the field to a smallint solved it.
Thanks again for the great control.
Pietro
I tried to reproduce and TinyInt works. Which provider do you use? I tested with "sqloledb".
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|