Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
I don't understand. If you want to forbid cell's editing then set AllowUserEditing to False (Default)
Nevermind. I found it already)
But I have another question: can you add autosave of data from grid to database (like MS DataGrid 6.0) after changing cells.
Last edited by SPB-667; Aug 10th, 2019 at 12:50 PM.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by SPB-667
But I have another question: can you add autosave of data from grid to database (like MS DataGrid 6.0) after changing cells.
This a replacement for the FlexGrid control and not for the DataGrid control. There is no direct binding available in the MSFlexGrid control, so the VBFlexGrid doesn't either.
However, in my opinion, it is anway better to have the database unbound to the grid. If you change something in the grid it's in your control what happens after that in the database.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi,
I've tried this on 2 different machines, both Win 10 64bit, but the IDE just crashes when I run, compile or try to view MainForm.
I've put the OLEGuids files in SysWOW64 and the IDE looks to find them OK. I have not registered them in any way. Just overwrote the old OLEGuids I had there.
Any ideas?
Update: removed "MainForm" and changed Sub Main() to show "UserEditingForm" instead and then the program runs fine.
-Leifster
Last edited by leifmb; Aug 29th, 2019 at 03:57 AM.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by leifmb
I've tried this on 2 different machines, both Win 10 64bit, but the IDE just crashes when I run, compile or try to view MainForm.
I've put the OLEGuids files in SysWOW64 and the IDE looks to find them OK. I have not registered them in any way. Just overwrote the old OLEGuids I had there.
Any ideas?
Update: removed "MainForm" and changed Sub Main() to show "UserEditingForm" instead and then the program runs fine.
To be honest. I understanding nothing what you are describing.
For me the MainForm works. And that only UserEditingForm works but not MainForm is an indication that it's not the VBFlexGrid's nor OLEGuids.tlb's fault.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I guess it's something wrong with my VB6 setup/installation then. I've seen similar behavior once or twice before.
Just tested on my 3rd VB6 machine and it has the very same problem :-(
Off topic: There are many different guides on how to install VB6 on Windows 10, all with some variations. Is there a definitive guide somewhere?
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by leifmb
I guess it's something wrong with my VB6 setup/installation then. I've seen similar behavior once or twice before.
Just tested on my 3rd VB6 machine and it has the very same problem :-(
Off topic: There are many different guides on how to install VB6 on Windows 10, all with some variations. Is there a definitive guide somewhere?
I suggest to ask this question in the general forum.
If it is of any comfort to you, from time to time (may be every two or three months) I need to uninstall and reinstall VB6 because I start to experience quasi random crashes of the IDE (I have Windows 10 - 64 bits).
I usually also clean the registry with a registry cleaner after uninstalling and before reinstalling (but I don't know if that is necessary).
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Often I need to indicate "sort arrows".
I would like to integrate such thing as a default in-built feature to reduce code lines on form level etc.
Any suggestions how to look like and integration?
I thought maybe with a .ColSortArrow property with enums None, Up and Down.
But how to draw, default or app should provide picture? How to align? (Text truncate problem?)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Bugfix in the ShowLabelTips property.
That property is intended to show tooltips on folded cells. However, it didn't show on fixed cells even though it was designed to work also on fixed cells.
The small bug was in the internal GetLabelInfo function.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I am using this grid in a program where I need to format (color) certain words in a cell (but not all). Possible? (I started a thread in VB6 And Earlier about (erroneously) RTBs.)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi Krool,
I'm binding VBFlexGrid to sqlite database
Code:
Set VBFlexGrid1.FlexDataSource = DataSource.BindTo(Rs)
However it is Impossile to sort columns order
I got a message: This funtionality is disabled when custom datasource is set
is there a work around?
thanks
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by newbie2
Hi Krool,
I'm binding VBFlexGrid to sqlite database
Code:
Set VBFlexGrid1.FlexDataSource = DataSource.BindTo(Rs)
However it is Impossile to sort columns order
I got a message: This funtionality is disabled when custom datasource is set
is there a work around?
thanks
The error says "functionality is disabled".
Reason is crystal clear as you have a virtual binding to a sqlite recordset.
If you want sorting - fine. Just append a "ORDER BY ..." in your sqlite SELECT statement.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
The error says "functionality is disabled".
Reason is crystal clear as you have a virtual binding to a sqlite recordset.
If you want sorting - fine. Just append a "ORDER BY ..." in your sqlite SELECT statement.
Thank you.
In fact I need to sort them after having fed the flexgrid control.
I have two command buttons.
one is
Code:
VBFlexGrid1.Sort = FlexSortGenericAscending
and the other is VBFlexGrid1.Sort = FlexSortGenericDescending
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by newbie2
Thank you.
In fact I need to sort them after having fed the flexgrid control.
I have two command buttons.
one is
Code:
VBFlexGrid1.Sort = FlexSortGenericAscending
and the other is VBFlexGrid1.Sort = FlexSortGenericDescending
In virtual bindig the grid is never fed. It just reads the data needed for the current view.
When you need to sort after binding then re-fetch the data again in your custom data source (SELECT statement with ORDER BY) and make a .Refresh on the VBFlexGrid so it reads the new current view.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
thanks again
I tested the two methods in the link provided but unluckily none of them succeeded
One method is not possible with virtual binding
And the the other method failed because VBFlexGrid seems not supporting CellPicture property.
Edit
I jus noticed in your Demo that CellPicture property is supported but in the sample demo provided in the link I get Method or Data member not found in the line
Code:
if VBFlexGrid1.CellPicture = picChecked then
Last edited by newbie2; Apr 8th, 2020 at 06:19 PM.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by newbie2
thanks again
I tested the two methods in the link provided but unluckily none of them succeeded
One method is not possible with virtual binding
And the the other method failed because VBFlexGrid seems not supporting CellPicture property.
Edit
I jus noticed in your Demo that CellPicture property is supported but in the sample demo provided in the link I get Method or Data member not found in the line
Code:
if VBFlexGrid1.CellPicture = picChecked then
I cannot reproduce your error. Please provide a demo.
I also recommend you to set CellPictureAlignment to 'FlexPictureAlignmentLeftCenterNoOverlap'.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by newbie2
Here is the demo
I should note that with the MSFlexGrid control doesn't throw the error
Thanks. I found the error.. Update released.
In the internal structure the cell picture is stored as 'IPictureDisp'.
However, somehow I exposed the cell picture back to the outside as 'IPicture'. (.CellPicture property)
And that 'IPicture' is not "comparable" via "If Pic1 = Pic2 Then".
I also updated the OCX version. Even as it was a "technical compatibility break" I choosed the "Preserve Compatibility (Advanced)" option.
Because in "real" it's not a compatibility break. Any app will continue to run as before.
So I encourage you to upgrade your 1.3 OCX you are currently using to the 1.4 OCX. (because 1.3 is not maintaned anymore)
If you want to stick with the 1.3 version there is this little workaround you can do:
Code:
Dim CellPic As IPictureDisp
Set CellPic = VBFlexGrid1.CellPicture
If CellPic = picChecked Then
If you go to 1.4 the above workaround is not necessary anymore. There you can do directly:
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thank you Krool for all these efforts you are doing.
I registrered the 1.4 OCX . I could avoid the error but
i still can't check / uncheck as I do with the MsFlexGrid.
I attached the wo demos. one is working fine with the MsFlexGrid and the other is not working as expected with the VBFlexGrid
Thank you
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I'm sorry
I should have set the VBFlexGrid in the control property to: Col = 1 Row = 1 FixedRows and Cols = 0
But something very strange is happening with virtual binding
I'm getting type mismatch error in
Code:
Set VBFlexGrid1.FlexDataSource = DataSource.BindTo(Rs)
When I drop version 1.4 and place Version 1.3, everything is OK
Last edited by newbie2; Apr 9th, 2020 at 05:56 PM.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by newbie2
I'm sorry
I should have set the VBFlexGrid in the control property to: Col = 1 Row = 1 FixedRows and Cols = 0
But something very strange is happening with virtual binding
I'm getting type mismatch error in
Code:
Set VBFlexGrid1.FlexDataSource = DataSource.BindTo(Rs)
When I drop version 1.4 and place Version 1.3, everything is OK
You need to change in your DataSource class the reference from IVBFlexDataSource from 1.3 to 1.4.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
You need to change in your DataSource class the reference from IVBFlexDataSource from 1.3 to 1.4.
There is no reference to the control version in the class
Code:
Option Explicit
Implements IVBFlexDataSource
Private mRs As cRecordset
'a Public Method, to allow Binding to an outside DataSource (in this case an SQLite-cRecordset)
Public Function BindTo(Rs As cRecordset) As IVBFlexDataSource
Set mRs = Rs
Set BindTo = Me 'return a reference of our Class-instance to the outside
End Function
'and the whole interface-implementation, which works against our internal SQLite-Recordset
Private Function IVBFlexDataSource_GetRecordCount() As Long
IVBFlexDataSource_GetRecordCount = mRs.RecordCount
End Function
Private Function IVBFlexDataSource_GetFieldCount() As Long
IVBFlexDataSource_GetFieldCount = mRs.Fields.Count
End Function
Private Function IVBFlexDataSource_GetFieldName(ByVal Field As Long) As String
IVBFlexDataSource_GetFieldName = mRs.Fields(Field).Name
End Function
Private Function IVBFlexDataSource_GetData(ByVal Field As Long, ByVal Record As Long) As String
IVBFlexDataSource_GetData = mRs.ValueMatrix(Record, Field)
End Function
Private Sub IVBFlexDataSource_SetData(ByVal Field As Long, ByVal Record As Long, ByVal NewData As String)
mRs.ValueMatrix(Record, Field) = NewData
End Sub
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by newbie2
There is no reference to the control version in the class
Code:
Option Explicit
Implements IVBFlexDataSource
Private mRs As cRecordset
'a Public Method, to allow Binding to an outside DataSource (in this case an SQLite-cRecordset)
Public Function BindTo(Rs As cRecordset) As IVBFlexDataSource
Set mRs = Rs
Set BindTo = Me 'return a reference of our Class-instance to the outside
End Function
'and the whole interface-implementation, which works against our internal SQLite-Recordset
Private Function IVBFlexDataSource_GetRecordCount() As Long
IVBFlexDataSource_GetRecordCount = mRs.RecordCount
End Function
Private Function IVBFlexDataSource_GetFieldCount() As Long
IVBFlexDataSource_GetFieldCount = mRs.Fields.Count
End Function
Private Function IVBFlexDataSource_GetFieldName(ByVal Field As Long) As String
IVBFlexDataSource_GetFieldName = mRs.Fields(Field).Name
End Function
Private Function IVBFlexDataSource_GetData(ByVal Field As Long, ByVal Record As Long) As String
IVBFlexDataSource_GetData = mRs.ValueMatrix(Record, Field)
End Function
Private Sub IVBFlexDataSource_SetData(ByVal Field As Long, ByVal Record As Long, ByVal NewData As String)
mRs.ValueMatrix(Record, Field) = NewData
End Sub
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Karl77
b)
click on fixed row's cell
select the whole column
You need to have the .AllowBigSelection set to True. Then a click on a fixed row's cell automatically selects the whole column.
Originally Posted by Karl77
a)
single click into cell = single cell selected
mouse down and drag = select cells in the column (!) only, same for shift+cursor
To restrict a "mouse selection dragging" only to the current column you can use following code sample:
Code:
Private LButtonPressed As Boolean
Private Sub VBFlexGrid1_BeforeSelChange(ByVal NewRowSel As Long, ByVal NewColSel As Long, Cancel As Boolean)
If LButtonPressed = True Then
If NewColSel <> VBFlexGrid1.ColSel Then Cancel = True
End If
End Sub
Private Sub VBFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then LButtonPressed = True
End Sub
Private Sub VBFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
LButtonPressed = False
End Sub
The extension to include also shift+cursor would look like:
Code:
Private LButtonPressed As Boolean
Private ShiftPressed As Boolean
Private Sub VBFlexGrid1_BeforeSelChange(ByVal NewRowSel As Long, ByVal NewColSel As Long, Cancel As Boolean)
If LButtonPressed = True Or ShiftPressed = True Then
If NewColSel <> VBFlexGrid1.ColSel Then Cancel = True
End If
End Sub
Private Sub VBFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
ShiftPressed = CBool((Shift And vbShiftMask) <> 0)
End Sub
Private Sub VBFlexGrid1_KeyUp(KeyCode As Integer, Shift As Integer)
ShiftPressed = CBool((Shift And vbShiftMask) <> 0)
End Sub
Private Sub VBFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then LButtonPressed = True
End Sub
Private Sub VBFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
LButtonPressed = False
End Sub
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by Krool
You need to have the .AllowBigSelection set to True. Then a click on a fixed row's cell automatically selects the whole column.
Yes, I knew, I mentioned it only because I didn't want to lose this functionality along with the new 'mode'.
To restrict a "mouse selection dragging" only to the current column you can use following code sample:
The extension to include also shift+cursor would look like:
Code:
Private LButtonPressed As Boolean
Private ShiftPressed As Boolean
Private Sub VBFlexGrid1_BeforeSelChange(ByVal NewRowSel As Long, ByVal NewColSel As Long, Cancel As Boolean)
If LButtonPressed = True Or ShiftPressed = True Then
If NewColSel <> VBFlexGrid1.ColSel Then Cancel = True
End If
End Sub
Private Sub VBFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
ShiftPressed = CBool((Shift And vbShiftMask) <> 0)
End Sub
Private Sub VBFlexGrid1_KeyUp(KeyCode As Integer, Shift As Integer)
ShiftPressed = CBool((Shift And vbShiftMask) <> 0)
End Sub
Private Sub VBFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then LButtonPressed = True
End Sub
Private Sub VBFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
LButtonPressed = False
End Sub
Works exactly as expected.
Thanks for you support Krool.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thank you for this great grid.
I found a bug in the latest version. If I set SelectionMode to any other value then Free and I have AllowUserEdit set to True, with a double click, I can only edit the first cell in the row or column and not the cell I double clicked.
And there is one property missing. There is now BackgoundColorAlt, but no ForegroundColorAlt.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Originally Posted by 0xDEADC0DE55
Thank you for this great grid.
I found a bug in the latest version. If I set SelectionMode to any other value then Free and I have AllowUserEdit set to True, with a double click, I can only edit the first cell in the row or column and not the cell I double clicked.
And there is one property missing. There is now BackgoundColorAlt, but no ForegroundColorAlt.
It's not a bug, it's a feature.
For SelectionMode Free, FreeByRow, FreeByCol it works as you desire.
For ByRow and ByCol it takes the first cell at it is the "focused" cell.
You can change behavior by code at the BeforeEdit event.
Check the "Reason" param for FlexEditReasonDblClick and as the Row and Col param in the event are "ByRef" you can make a .HitTest and apply .HitRow and .HitCol to it. (Or more convenient use .MouseRow and .MouseCol)
Everyone has different desires, therefore there is a strict flat default behavior and such extra things need to be done via code.
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Significant performance boost for the drawing operation.
~2% for
Usage of Polyline API (not PolylineTo !) instead of MoveToEx and LineTo. (for the grid lines)
Polyline is at device driver level, thus faster than LineTo and it doesn't change current position.
~1% for
Usage of PatBlt API instead of FillRect. (FillRect is a wrapper of PatBlt SelectObject'ing the specified Brush)
Of course when each cell has a different backcolor the effect is equal to FillRect.
~5% for
Preserving the memory DC & Bitmap (DoubleBuffer) for WM_PAINT and purge only upon WM_SIZE. (and cleanup on destroy window)