-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I noticed a bug for 'FlexAlignmentGeneral'.
Currently it right aligns for numbers and left aligns for text.
However, it should right align for numbers and dates !
It's embarrassing that it could withstand since initial release.. so now it is fixed.
Generic sorting will still sort only numbers and strings. (no dates; like in MS(H)FlexGrid)
So keep using FlexSortDateAscending/FlexSortDateDescending for dates.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
I noticed a bug...
Found an additional one in 1.5.1, I think - not showing a HScrollbar, when .Cols < 3
e.g. with Cols = 2 ... and ColWidth(1) via code set larger than the Grid-Width -
(generally, not only when working in IVBFlexDataSource-Mode).
Olaf
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Schmidt
Found an additional one in 1.5.1, I think - not showing a HScrollbar, when .Cols < 3
e.g. with Cols = 2 ... and ColWidth(1) via code set larger than the Grid-Width -
(generally, not only when working in IVBFlexDataSource-Mode).
Olaf
How is FixedCols set?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
How is FixedCols set?
The Fixed-Props are at their defaults: 1
Olaf
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Schmidt
The Fixed-Props are at their defaults: 1
Olaf
Ok then it's by design to have no H-Scrollbar since there is only 1 scrollable col, which extends beyond client rect. It simply can't scroll..
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
Ok then it's by design to have no H-Scrollbar since there is only 1 scrollable col, which extends beyond client rect. It simply can't scroll..
Right, sorry for the noise...
(forgot, that the Flex does not support Pixel-based HScrolling, but scrolls "integral, whole Cols" instead)
Olaf
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi,
(Newbie here !!)
I notice a change in behaviour with msflexgrid, this code was written 30 years ago by someone else for the old grid32. I converted it to msflexgrid, but since the redraw screen on win10 on some occasion was flashy and long, I decided to test this version.
In the previous control, a fix column will obey the Grid1.ColAlignment(0) = 4 (FlexAlignmentCenterCenter) , but with the current it's not, I remove the fix column = 1 argument and it works.
Maybe there's another function to call to align a fix column? but the way I see it, it's not a direct replacement then !
Thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
jffortier
Hi,
(Newbie here !!)
I notice a change in behaviour with msflexgrid, this code was written 30 years ago by someone else for the old grid32. I converted it to msflexgrid, but since the redraw screen on win10 on some occasion was flashy and long, I decided to test this version.
In the previous control, a fix column will obey the Grid1.ColAlignment(0) = 4 (FlexAlignmentCenterCenter) , but with the current it's not, I remove the fix column = 1 argument and it works.
Maybe there's another function to call to align a fix column? but the way I see it, it's not a direct replacement then !
Thanks
There is ColAlignment and FixedAlignment.
ColAlignment overwrites the FixedAlignment when FixedAlignment is not explicitly set.
Can you share the code so I can replicate the potential issue?
Thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
First of all, wish you a great new year.
Ask him about drag and drop between columns, outside and inside a vbgrid to another vbgrid (grid1 to grid2) and about the merged cell, to be able to build a kanban. Thanks a lot
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hello Krool,
I'm testing the VBFlexGrid, I'm doing it with the ocx version (latest, 1.5), and I found that when there are no rows, the AddItem method raises an error.
To test it, with a new added VBFlexGrid control to a form, this is the code:
Code:
Private Sub Form_Load()
VBFlexGrid1.FixedRows = 0
VBFlexGrid1.Rows = 0
End Sub
Private Sub Command1_Click()
VBFlexGrid1.AddItem "AA" & vbTab & "BB"
VBFlexGrid1.Refresh
End Sub
The same code works with the MSHFlexGrid without raising an error.
Also, I noticed that if I don't add the VBFlexGrid1.Refresh, the grid is not visually updated until I click on it, unlike the MSHFlexGrid.
I don't know whether these differences are on purpose or a bug.
Thanks.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Eduardo-
Hello Krool,
I'm testing the VBFlexGrid, I'm doing it with the ocx version (latest, 1.5), and I found that when there are no rows, the AddItem method raises an error.
To test it, with a new added VBFlexGrid control to a form, this is the code:
Code:
Private Sub Form_Load()
VBFlexGrid1.FixedRows = 0
VBFlexGrid1.Rows = 0
End Sub
Private Sub Command1_Click()
VBFlexGrid1.AddItem "AA" & vbTab & "BB"
VBFlexGrid1.Refresh
End Sub
The same code works with the MSHFlexGrid without raising an error.
Also, I noticed that if I don't add the
VBFlexGrid1.Refresh, the grid is not visually updated until I click on it, unlike the MSHFlexGrid.
I don't know whether these differences are on purpose or a bug.
Thanks.
Good catch. That's a bug. Fixed now.
Thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi Krool,
I don't know how to make a allowed formated input,for example, allow a float number with "+" or "-" or a scientific ... can I?
Thanks in advance.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi Krool,
How to make a formated input , such as add a float number with "+", or "-", or a scientific ...
Thanks.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
hi,i have a simple form with adodc control and this gird
i want set datasource of this gird to adodc1 and then
how can add new record synced with grid or delete or refresh or edit used by grid
i did not find any sample about example use access data with this girl in download folder.
any body can send a simple project to can work with access binded to gird here ?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Black_Storm
...how can add new record synced with grid or delete or refresh or edit used by grid
The Grid supports an IVBFlexDataSource interface for such Binding-scenarios.
This interface operates only on "simple string-types" (not specific Recordset-Types).
So, you can bind not only Recordsets, but also "any 2D-Array" or "JSON-Collection" or whatever.
A small example-implementation (which does a binding to SQLite-Recordsets) can be studied here:
https://www.vbforums.com/showthread....te-Recordsets)
Olaf
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
why datasource property designed in this grid control but i should be use like as ur class and use IVBFlexDataSource ?!!
if this property designed for bind to any data control so how can use it ? any sample?
do u have any simple sample to i jst set this property to a adodc1?
i did see your topic before i ask my question here but i don't want fill my grid with coding and run query for each update or delete and like these actions,i want use like as data grid and binded automatically to adodc1
for example can i set this grid.DataSource = adodc1 in design and then just work with adodc1 like as adodc1.recordset.addnew or update or refresh or movefirtst move last and etc automatically binded to gird ?and i did not see retrieve field on rightclick on grid or change captions or fields binded and like these options...
so i think i can use bind between this grid and adodc or ... just with coding and do I have to do this for anything I need? .
if u know any datagrid (not like as vhflexgrid) to support cool theme (skins) and righttoleft layout?
i dont know yet maybe this grid support change skin or theme with coding if possible any sample code?
i found some but they have problem with righttoleft layout (like as jgrid or something better than jgrid) or trials...
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Black_Storm
why datasource property designed in this grid control but i should be use like as ur class and use IVBFlexDataSource ?!!
if this property designed for bind to any data control so how can use it ? any sample?
do u have any simple sample to i jst set this property to a adodc1?
i did see your topic before i ask my question here but i don't want fill my grid with coding and run query for each update or delete and like these actions,i want use like as data grid and binded automatically to adodc1
for example can i set this grid.DataSource = adodc1 in design and then just work with adodc1 like as adodc1.recordset.addnew or update or refresh or movefirtst move last and etc automatically binded to gird ?and i did not see retrieve field on rightclick on grid or change captions or fields binded and like these options...
so i think i can use bind between this grid and adodc or ... just with coding and do I have to do this for anything I need? .
if u know any datagrid (not like as vhflexgrid) to support cool theme (skins) and righttoleft layout?
i dont know yet maybe this grid support change skin or theme with coding if possible any sample code?
i found some but they have problem with righttoleft layout (like as jgrid or something better than jgrid) or trials...
The .DataSource property is not binding for CRUD.
It's just reading a recordset and filling the grid.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Krool,
Several 'Pages' ago in the thread, you spoke about altering the ClipMode options, so that Fixed Cols/Rows could be included/excluded as required. Is this something still on the cards.
Am looking at migrating my system to use the new grid, and am slowly updating my 'helper' functions to work with the new grid. Now looking at my function to send the whole grid to excel. I'm hoping this will be a lot neater using the Clip function, but I would like the header to be copied across. I can do this in code, but if the ClipMode alterations are still on the to-do list that would make it easier/neater
Thanks
Lee.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Krool,
when I fill the VBFlexGrid from database the records are displayed fine.
but when I fill by code it is showing strange symbols.
I'm using Arabic Egypt in regional setting.
Is there a workaround?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Mustaphi
Krool,
when I fill the VBFlexGrid from database the records are displayed fine.
but when I fill by code it is showing strange symbols.
I'm using Arabic Egypt in regional setting.
Is there a workaround?
Use a different font. E.g. Microsoft Sans Serif instead of MS Sans Serif.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Krool
Use a different font. E.g. Microsoft Sans Serif instead of MS Sans Serif.
thanks but it didn'thelp
still strange symbols
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Mustaphi
Krool,
when I fill the VBFlexGrid from database the records are displayed fine.
but when I fill by code it is showing strange symbols.
I'm using Arabic Egypt in regional setting.
Is there a workaround?
How do you obtain the information to be put in the vbFlexGrid?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Arnoutdv
How do you obtain the information to be put in the vbFlexGrid?
With VBFlexGrid1
.AddItem ""
.TextMatrix(1, 1) = "test data"
.TextMatrix(1, 2) = "test data"
End With
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
That's just hardcoded plain ASCII text.
How do you obtain your Arabic texts?
From a text file? From user input?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Arnoutdv
That's just hardcoded plain ASCII text.
How do you obtain your Arabic texts?
From a text file? From user input?
in fact I'm binding the grid to database
Code:
Set .FlexDataSource = DataSource.BindTo(Rs)
I just need to hardcode the columnheders.
Code:
.TextMatrix(0, 1) = "الرقم"
.TextMatrix(0, 2) = "التاريخ"
.TextMatrix(0, 3) = "الاسم"
thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Mustaphi
in fact I'm binding the grid to database
Code:
Set .FlexDataSource = DataSource.BindTo(Rs)
I just need to hardcode the columnheders.
Code:
.TextMatrix(0, 1) = "الرقم"
.TextMatrix(0, 2) = "التاريخ"
.TextMatrix(0, 3) = "الاسم"
thanks
Maybe your PC (non-unicode language settings) is in Arabic, thus DBCS mode is on. That's why you can place "fake" unicode in the VB6 IDE but in fact in other language (non-DBCS mode) will fail .
It's just a guess out of the blue..
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
hi krool
I'm using this code to send data from VBFlexGrid to excel.
The vb6 FlexGrid is showing Arabic quite normal in theexcel sheet but VBFlexGrid is showing strange symbols.
Code:
Private Sub FlexToExcel()
Dim xlObject As Excel.Application
Dim xlWB As Excel.Workbook
Set xlObject = New Excel.Application
'This Adds a new woorkbook, you could open the workbook from file also
Set xlWB = xlObject.Workbooks.Add
Clipboard.Clear 'Clear the Clipboard
With MSFlexGrid1
'Select Full Contents (You could also select partial content)
.Col = 1 'From first column
.Row = 0 'From first Row (header)
'.ColSel = .Cols - 1 'Select all columns
.RowSel = .Rows - 1 'Select all rows
Clipboard.SetText .Clip 'Send to Clipboard
End With
With xlObject.ActiveWorkbook.ActiveSheet
.Cells(1, 1)Select 'Select Cell A1 (will paste from here, to different cells)
.Paste 'Paste clipboard contents
.Columns(1).Font.Bold = True
.Columns(1).HorizontalAlignment = xCenter
End With
'-------------------------------------------------
Clipboard.Clear 'Clear the Clipboard
With MSFlexGrid1
'Select Full Contents (You could also select partial content)
.Col = 4 'From first column
.Row = 0 'From first Row (header)
'.ColSel = .Cols - 1 'Select all columns
.RowSel = .Rows - 1 'Select all rows
Clipboard.SetText .Clip 'Send to Clipboard
End With
With xlObject.ActiveWorkbook.ActiveSheet
.Cells(1, 2)Select 'Select Cell A1 (will paste from here, to different cells)
.Paste 'Paste clipboard contents
.Columns(2).Font.Bold = True
.Columns(2).HorizontalAlignment = xCenter
End With
' This makes Excel visible
xlObject.Visible = True
End Sub
-
1 Attachment(s)
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I noticed that if the input /keyboard language is Arabic everything is OK.
But if the the input language is english, it shows as weird characters in excel sheet.
I'm referring to the Keyboad language (the one in the right bottom of the screen) not in regional settings.
Attachment 184238
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi,
I'm using MouseRow to detect the row the user is clicking on. With the left mouse click, this returns the correct row. However, if I right mouse click on a row, MouseRow returns the currently selected row. For example: I have a grid with the first row fixed as column headers, and 4 rows with data below that. The last row is selected, i.e. MouseRow returns 4. If I right mouse click on another row, MouseRow will always return 4, while a left mouse click would return the correct rownumber.
Am I doing something wrong, or am I missing something?
Thanks,
Erwin
[Edit] Additional info
I have a VBFlexGrid called grdFixtureList with a fixed header row, and several rows of data. The below code creates a popup menu depending on where the user clickied. A strange thing happens if I place a breakpoint on the line "If .Row < .RowSel Then". I right mouse clicked on another row than the one that was selected. Now, if I move the mouse cursor over the first instance of .MouseRow above the comment User clicked selected area) the labeltip give me another value than when I place the mouse over the last instance of .MouseRow below the comment User clicked a new row.
One property having two different values at the same time? Something strange is happening.
Code:
Private Sub grdFixtureList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim iStartRow As Integer
Dim iEndRow As Integer
Dim iSelectedPopUpMenuItem As Integer
If (Button = vbRightButton) And (grdFixtureList.Rows > 1) Then
'Select the row the user clicked on
With grdFixtureList
'If the user clicked on one or more selected Fixtures, pop up the menu, otherwise select the row
If .Row < .RowSel Then
iStartRow = .Row
iEndRow = .RowSel
Else
iStartRow = .RowSel
iEndRow = .Row
End If
If (.MouseRow >= iStartRow) And (.MouseRow <= iEndRow) Then
'User clicked selected area
If iStartRow = iEndRow Then
'Only one item selected, show/hide appropriate menu-items
iSelectedPopUpMenuItem = CreateMenuPopUpFixtureList(LIST_POPUP_MENU_SINGLE_ITEM)
Else
'Multiple items selected, show/hide appropriate menu-items
iSelectedPopUpMenuItem = CreateMenuPopUpFixtureList(LIST_POPUP_MENU_MULTIPLE_ITEMS)
End If
Else
'User clicked a new row. Simulate a click to have the item selected in the floorplan and then show the menu
.Row = .MouseRow
Call grdFixtureList_Click
iSelectedPopUpMenuItem = CreateMenuPopUpFixtureList(LIST_POPUP_MENU_SINGLE_ITEM)
End If
End With
'Process the selected menuitem
Select Case iSelectedPopUpMenuItem
Case 0
'User didn't select any menu
Case 1
Call mnuPopUpChangeFixture_Click
Case 2
Call mnuPopUpDuplicateFixture_Click
Case 3
Call mnuPopUpRemoveFixture_Click
Case 4
Call mnuPopUpRemoveFixture_Click
End Select
End If
End Sub
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
There is a problem in Win10 with the DPI, other than that how would I send a regular size file? I have vbflexgrid with some more features, but it is impossible for me to upload to the server
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Excuse me group, will there be a group like Whatsapp or Telegram?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Add a Row use "Additem". I want to Add a Col.What I use?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
fengzhongxia
Add a Row use "Additem". I want to Add a Col.What I use?
Code:
VSFlexGrid1.Cols = number_of_columns_that_you_want
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi Krool,
I'm thinking about a question, can we develop a VBFlex-like control without subclassing and VTable? In other words, what features/functions in the subclass cannot be replaced by other technologies?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hi: Krool
please visit url: https://github.com/lizanodiaz/vbflexgrid
there are many improvements that you can implement in your vbflexgrid, like progress bars, toggle button, etc. The purpose is to have a good, more powerful and functional grid (note the original grid has some DPI problems in windows 10).
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Small update release.
Setting .FlexDataSource to nothing will invalidate the grid now and does not cause an immediate redraw anymore.
I got a scenario where that forced complete redraw is annyoing. So having just the invalidation is fine.
If somebody want's to continue to have an immediate redraw, one can do so by a following .Refresh code line.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hello, Krool.
The colPosition() and rowPosition() properties should move the column resp. row not swap them.
Is this by design? If so, could you implement the 'original' behavior to the VBFlexgrid?
Thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
Seniorchef
Hello, Krool.
The colPosition() and rowPosition() properties should move the column resp. row not swap them.
Is this by design? If so, could you implement the 'original' behavior to the VBFlexgrid?
Thanks
There is the RowPos() and RowPosition() properties (and Col resp.) and they already behave like in msFlexGrid.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Hello!
No, the don't.
The colPosition() in VBFl,exGrid swaps two columns:
colPosition(6)=10 in VBFlexGrid results in columns 5,10,7,8,9,6,11 ...
colPosition(6)=10 in MSHFlexGrid results in columns 5,7,8,9,10,6,11...
rowPosition() behave the same.
Greetings
That is colPosition(6)=10 cols 6 and 10 get swapped, nothing else changes. MSFlexGrid moves column 6 behind column ten, so the new order is 5,7,8,9,10,6,11
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Oops, sorry for the lines after greetings :-)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I changed the ColPosition/RowPosition as follows (quick and dirty):
Code:
Public Property Let ColPosition(ByVal Index As Long, ByVal Value As Long)
If (Index < 0 Or Index > (PropCols - 1)) Or (Value < 0 Or Value > (PropCols - 1)) Then Err.Raise Number:=381, Description:="Subscript out of range"
If Index = Value Then Exit Property
'Bisher:
Dim i As Long, Swap1 As TCELL, Swap2 As TCOLINFO
On Error Resume Next
'For i = 0 To (PropRows - 1)
' With VBFlexGridCells.Rows(i)
' LSet Swap1 = .Cols(Index)
' LSet .Cols(Index) = .Cols(Value)
' LSet .Cols(Value) = Swap1
' End With
'Next i
'LSet Swap2 = VBFlexGridColsInfo(Index)
'LSet VBFlexGridColsInfo(Index) = VBFlexGridColsInfo(Value)
'LSet VBFlexGridColsInfo(Value) = Swap2
'SeniorChef...
Dim nCol&
If Index < Value Then
For i = 0 To PropRows - 1
With VBFlexGridCells.Rows(i)
LSet Swap1 = .Cols(Index)
For nCol = Index To Value - 1
LSet .Cols(nCol) = .Cols(nCol + 1)
Next
LSet .Cols(Value) = Swap1
End With
Next
LSet Swap2 = VBFlexGridColsInfo(Index)
For nCol = Index To Value
LSet VBFlexGridColsInfo(nCol) = VBFlexGridColsInfo(nCol + 1)
Next
LSet VBFlexGridColsInfo(Value) = Swap2
ElseIf Index > Value Then
For i = 0 To PropRows - 1
With VBFlexGridCells.Rows(i)
LSet Swap1 = .Cols(Index)
For nCol = Index To Value + 1 Step -1
LSet .Cols(nCol) = .Cols(nCol - 1)
Next
LSet .Cols(Value) = Swap1
End With
Next
LSet Swap2 = VBFlexGridColsInfo(Index)
For nCol = Index To Value Step -1
LSet VBFlexGridColsInfo(nCol) = VBFlexGridColsInfo(nCol - 1)
Next
LSet VBFlexGridColsInfo(Value) = Swap2
End If
'End SeniorChef
Dim RCP As TROWCOLPARAMS
With RCP
.Mask = RCPM_LEFTCOL
.Flags = RCPF_CHECKLEFTCOL Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
.LeftCol = VBFlexGridLeftCol
Call SetRowColParams(RCP)
End With
End Property
Public Property Let RowPosition(ByVal Index As Long, ByVal Value As Long)
If (Index < 0 Or Index > (PropRows - 1)) Or (Value < 0 Or Value > (PropRows - 1)) Then Err.Raise Number:=381, Description:="Subscript out of range"
If Index = Value Then Exit Property
Dim Swap As TCOLS
'bisher:
'With VBFlexGridCells
'LSet Swap = .Rows(Index)
'LSet .Rows(Index) = .Rows(Value)
'LSet .Rows(Value) = Swap
'End With
'SeniorChef:
With VBFlexGridCells
LSet Swap = .Rows(Index)
Dim nRow&
If Index < Value Then
For nRow = Index To Value - 1
LSet .Rows(nRow) = .Rows(nRow + 1)
Next
ElseIf Index > Value Then
For nRow = Index To Value + 1 Step -1
LSet .Rows(nRow) = .Rows(nRow - 1)
Next
End If
LSet .Rows(Value) = Swap
End With
'End SeniorChef
Dim RCP As TROWCOLPARAMS
With RCP
.Mask = RCPM_TOPROW
.Flags = RCPF_CHECKTOPROW Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
.TopRow = VBFlexGridTopRow
Call SetRowColParams(RCP)
End With
End Property
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
BTW, regarding my posts #595 ff I also implemented in my personal vbFlexGrid a method to sort the grid by cols that are not beneath each other, and also mix ascending and descending. It's about 30 lines of code:
Code:
'Add Enum
Public Enum FlexSortConstants
...
FlexSortUseIndex = 15
End Enum
'Add Array
Private FlexGridSortCols() As Long
'Quick and dirty properties
Public Property Get SortColIndex(ByVal Index As Long) As Long
If Index < 0 Or Index > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
SortColIndex = FlexGridSortCols(Index)
End Property
'There are better ways to fill the array and check the bounds
'SeniorChef
Public Property Let SortColIndex(ByVal Index As Long, ByVal Value As Long)
If Index <> -1 And (Index < 0 Or Index > (PropCols - 1)) Then Err.Raise Number:=30010, Description:="Invalid SortColIndex value"
If Value < 0 Or Value > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
'set a value, one after the other, this is not time critical, so redim preserve is ok...
If Index > -1 Then
ReDim Preserve FlexGridSortCols(Index)
FlexGridSortCols(Index) = Value
Else
'clear Array
ReDim FlexGridSortCols(0)
End If
End Property
'the improved sort method:
Public Property Let Sort(ByVal Value As FlexSortConstants)
#If ImplementFlexDataSource Then
If Not VBFlexGridFlexDataSource Is Nothing Then Err.Raise Number:=5, Description:="This functionality is disabled when custom data source is set."
#End If
Select Case Value
'changes from Seniorchef
'added FlexSortIndex as a legal Value
Case FlexSortNone, FlexSortGenericAscending, FlexSortGenericDescending, _
FlexSortNumericAscending, FlexSortNumericDescending, _
FlexSortStringNoCaseAscending, FlexSortStringNoCaseDescending, _
FlexSortStringAscending, FlexSortStringDescending, FlexSortCustom, _
FlexSortUseColSort, FlexSortCurrencyAscending, FlexSortCurrencyDescending, _
FlexSortDateAscending, FlexSortDateDescending, FlexSortUseIndex
VBFlexGridSort = Value
If VBFlexGridSort = FlexSortNone Then Exit Property
If (VBFlexGridRow < 0 Or VBFlexGridRowSel < 0) Or (VBFlexGridCol < 0 Or VBFlexGridColSel < 0) Then
' Error shall not be raised. Do nothing in this case.
Exit Property
End If
Dim SelRange As TCELLRANGE, iCol As Long, Sort As FlexSortConstants
Call GetSelRangeStruct(SelRange)
'changes from Seniorchef
'Doing the FlexSortIndex-Sort by taking the column to be sorted from the array FlexGridSortCols()
'rather than using Col and Colsel properties.
'SeniorChef
If VBFlexGridSort = FlexSortUseIndex Then
Dim iIndex As Long
For iIndex = UBound(FlexGridSortCols) To 0 Step -1
iCol = FlexGridSortCols(iIndex)
Sort = VBFlexGridColsInfo(iCol).Sort
' MergeSort is used for automatic sorting as it is fast and reliable.
If VBFlexGridRow = VBFlexGridRowSel Then
Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
Else
Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
End If
Next iIndex
Else
'no more changes
' The keys used for sorting are determined by the Col and ColSel properties.
' To specify the range to be sorted, set the Row and RowSel properties.
' Sorting is always done in a left-to-right direction. (Technically the sorting is performed from right-to-left)
For iCol = SelRange.RightCol To SelRange.LeftCol Step -1
If VBFlexGridSort <> FlexSortUseColSort Then Sort = VBFlexGridSort Else Sort = VBFlexGridColsInfo(iCol).Sort
' MergeSort/BubbleSort are used as they are 'stable sort' algorithms.
If Sort <> FlexSortCustom Then
' MergeSort is used for automatic sorting as it is fast and reliable.
If VBFlexGridRow = VBFlexGridRowSel Then
Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
Else
Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
End If
Else
' BubbleSort is used for custom sorting as row1/row2 for text matrix must be meaningful in the 'Compare' event.
If VBFlexGridRow = VBFlexGridRowSel Then
Call BubbleSortIter(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows())
Else
Call BubbleSortIter(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows())
End If
End If
Next iCol
End If
Dim RCP As TROWCOLPARAMS
With RCP
.Mask = RCPM_TOPROW
.Flags = RCPF_CHECKTOPROW Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
.TopRow = VBFlexGridTopRow
End With
If VBFlexGridIndirectCellRef.InProc = False Then
Call SetRowColParams(RCP)
Else
LSet VBFlexGridIndirectCellRef.RCP = RCP
VBFlexGridIndirectCellRef.SetRCP = True
End If
Case Else
Err.Raise 380
End Select
' Action-type property. Not real property.
End Property
Code:
'To sort a grid on columns 8, 6, 3, 9:
With VBFlexGrid
.sortColIndex(0)=8
.sortColIndex(1)=6
.sortColIndex(2)=3
.sortColIndex(3)=9
'How to sort each column
.colSort(8)=FlexSortStringNoCaseAscending
.colSort(6)=FlexSortDateDescending
.colSort(3)=FlexSortNumericAscending
.colSort(9)=FlexSortNUmericDescending
'Finally...
.sort = flexSortUseIndex
End with
Feel free to use this in the next update.
Thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Bugfix in the .RowPosition() and .ColPosition() property. (thanks to Seniorchef for reporting this)
Now it is a round trip swap instead of a direct swap between index and value.
This behavior matches now to the MS(H)FlexGrid control.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Thanks for your below suggestion. I think it's not necessary.
The below code would do the same:
Code:
With VBFlexGrid1
.ColSort(8) = FlexSortStringNoCaseAscending
.ColSort(6) = FlexSortDateDescending
.ColSort(3) = FlexSortNumericAscending
.ColSort(9) = FlexSortNumericDescending
.Cell(FlexCellSort, .FixedRows, 8, .Rows - 1) = FlexSortUseColSort
.Cell(FlexCellSort, .FixedRows, 6, .Rows - 1) = FlexSortUseColSort
.Cell(FlexCellSort, .FixedRows, 3, .Rows - 1) = FlexSortUseColSort
.Cell(FlexCellSort, .FixedRows, 9, .Rows - 1) = FlexSortUseColSort
End With
or (alternatively)
Code:
With VBFlexGrid1
.Cell(FlexCellSort, .FixedRows, 8, .Rows - 1) = FlexSortStringNoCaseAscending
.Cell(FlexCellSort, .FixedRows, 6, .Rows - 1) = FlexSortDateDescending
.Cell(FlexCellSort, .FixedRows, 3, .Rows - 1) = FlexSortNumericAscending
.Cell(FlexCellSort, .FixedRows, 9, .Rows - 1) = FlexSortNumericDescending
End With
Quote:
Originally Posted by
Seniorchef
BTW, regarding my posts #595 ff I also implemented in my personal vbFlexGrid a method to sort the grid by cols that are not beneath each other, and also mix ascending and descending. It's about 30 lines of code:
Code:
'Add Enum
Public Enum FlexSortConstants
...
FlexSortUseIndex = 15
End Enum
'Add Array
Private FlexGridSortCols() As Long
'Quick and dirty properties
Public Property Get SortColIndex(ByVal Index As Long) As Long
If Index < 0 Or Index > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
SortColIndex = FlexGridSortCols(Index)
End Property
'There are better ways to fill the array and check the bounds
'SeniorChef
Public Property Let SortColIndex(ByVal Index As Long, ByVal Value As Long)
If Index <> -1 And (Index < 0 Or Index > (PropCols - 1)) Then Err.Raise Number:=30010, Description:="Invalid SortColIndex value"
If Value < 0 Or Value > (PropCols - 1) Then Err.Raise Number:=30010, Description:="Invalid SortCol value"
'set a value, one after the other, this is not time critical, so redim preserve is ok...
If Index > -1 Then
ReDim Preserve FlexGridSortCols(Index)
FlexGridSortCols(Index) = Value
Else
'clear Array
ReDim FlexGridSortCols(0)
End If
End Property
'the improved sort method:
Public Property Let Sort(ByVal Value As FlexSortConstants)
#If ImplementFlexDataSource Then
If Not VBFlexGridFlexDataSource Is Nothing Then Err.Raise Number:=5, Description:="This functionality is disabled when custom data source is set."
#End If
Select Case Value
'changes from Seniorchef
'added FlexSortIndex as a legal Value
Case FlexSortNone, FlexSortGenericAscending, FlexSortGenericDescending, _
FlexSortNumericAscending, FlexSortNumericDescending, _
FlexSortStringNoCaseAscending, FlexSortStringNoCaseDescending, _
FlexSortStringAscending, FlexSortStringDescending, FlexSortCustom, _
FlexSortUseColSort, FlexSortCurrencyAscending, FlexSortCurrencyDescending, _
FlexSortDateAscending, FlexSortDateDescending, FlexSortUseIndex
VBFlexGridSort = Value
If VBFlexGridSort = FlexSortNone Then Exit Property
If (VBFlexGridRow < 0 Or VBFlexGridRowSel < 0) Or (VBFlexGridCol < 0 Or VBFlexGridColSel < 0) Then
' Error shall not be raised. Do nothing in this case.
Exit Property
End If
Dim SelRange As TCELLRANGE, iCol As Long, Sort As FlexSortConstants
Call GetSelRangeStruct(SelRange)
'changes from Seniorchef
'Doing the FlexSortIndex-Sort by taking the column to be sorted from the array FlexGridSortCols()
'rather than using Col and Colsel properties.
'SeniorChef
If VBFlexGridSort = FlexSortUseIndex Then
Dim iIndex As Long
For iIndex = UBound(FlexGridSortCols) To 0 Step -1
iCol = FlexGridSortCols(iIndex)
Sort = VBFlexGridColsInfo(iCol).Sort
' MergeSort is used for automatic sorting as it is fast and reliable.
If VBFlexGridRow = VBFlexGridRowSel Then
Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
Else
Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
End If
Next iIndex
Else
'no more changes
' The keys used for sorting are determined by the Col and ColSel properties.
' To specify the range to be sorted, set the Row and RowSel properties.
' Sorting is always done in a left-to-right direction. (Technically the sorting is performed from right-to-left)
For iCol = SelRange.RightCol To SelRange.LeftCol Step -1
If VBFlexGridSort <> FlexSortUseColSort Then Sort = VBFlexGridSort Else Sort = VBFlexGridColsInfo(iCol).Sort
' MergeSort/BubbleSort are used as they are 'stable sort' algorithms.
If Sort <> FlexSortCustom Then
' MergeSort is used for automatic sorting as it is fast and reliable.
If VBFlexGridRow = VBFlexGridRowSel Then
Call MergeSortRec(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows(), Sort)
Else
Call MergeSortRec(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows(), Sort)
End If
Else
' BubbleSort is used for custom sorting as row1/row2 for text matrix must be meaningful in the 'Compare' event.
If VBFlexGridRow = VBFlexGridRowSel Then
Call BubbleSortIter(PropFixedRows, PropRows - 1, iCol, VBFlexGridCells.Rows())
Else
Call BubbleSortIter(SelRange.TopRow, SelRange.BottomRow, iCol, VBFlexGridCells.Rows())
End If
End If
Next iCol
End If
Dim RCP As TROWCOLPARAMS
With RCP
.Mask = RCPM_TOPROW
.Flags = RCPF_CHECKTOPROW Or RCPF_SETSCROLLBARS Or RCPF_FORCEREDRAW
.TopRow = VBFlexGridTopRow
End With
If VBFlexGridIndirectCellRef.InProc = False Then
Call SetRowColParams(RCP)
Else
LSet VBFlexGridIndirectCellRef.RCP = RCP
VBFlexGridIndirectCellRef.SetRCP = True
End If
Case Else
Err.Raise 380
End Select
' Action-type property. Not real property.
End Property
Code:
'To sort a grid on columns 8, 6, 3, 9:
With VBFlexGrid
.sortColIndex(0)=8
.sortColIndex(1)=6
.sortColIndex(2)=3
.sortColIndex(3)=9
'How to sort each column
.colSort(8)=FlexSortStringNoCaseAscending
.colSort(6)=FlexSortDateDescending
.colSort(3)=FlexSortNumericAscending
.colSort(9)=FlexSortNUmericDescending
'Finally...
.sort = flexSortUseIndex
End with
Feel free to use this in the next update.
Thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Yep - the results seem the same.
It's really hard to know all the possibilities of the control.
Thank's for your efforts in this point.
And of course thank's for the control!
Regards
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Use RemoveItem ,Wheel will invalid!
please fix it !
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
fengzhongxia
Use RemoveItem ,Wheel will invalid!
please fix it !
Please more context.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Mr. Krool, why don't you use the files that I shared? Progress cells, chart cells, and many other things would have already been done. I hope you reconsider, thanks
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
fengzhongxia
Use RemoveItem ,Wheel will invalid!
please fix it !
Update released. Fixed.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Bugfix for FlexFocusRectFlat. The pen style uses now a NULL_BRUSH to not affect custom background color/picture.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Love the CellComboCue. Question - is there a way for this to be persistent in a cell? My understanding is that it is a dynamic cue on a cell event. We are considering the case of new users that might benefit from the persistent visual cue of the dropdown button. Thanks!
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
TheLeePiper
Love the CellComboCue. Question - is there a way for this to be persistent in a cell? My understanding is that it is a dynamic cue on a cell event. We are considering the case of new users that might benefit from the persistent visual cue of the dropdown button. Thanks!
It can be dynamic or persistent. Both ways are possible.
ComboCue/ComboCueRow/Col are dynamic.
CellComboCue is persistent. Best way to FillStyle that for whole Column via .Cell property (virtual selection)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Got it. Fantastic. Thanks so much for the assist and your efforts at large.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Question regarding the ComboDropDown function. I have set up a cell as a DropDown with the Cue working great. If I click the body of the cell, it properly drops the list, and grid.Row correctly is the current grid row of the DropDown cell. However, if I drop the list using the button itself, grid.Row is the previously entered grid row (and not the DropDown grid row). Is this the expected behavior? (Also note that the ValidateEdit function is also subsequently fired with the correct grid.Row in both cases.)
Additionally, if I click on the list item that is the current ComboListIndex, neither of these evens are fired. For example, say I have a list A & B, and A was previously selected. If I select A again, the events are not fired. If I select B, they are fired. Expected behavior? (This is less of an issue because data doesn't change, but it is curious that the events didn't fire.)
Thanks!
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Quote:
Originally Posted by
TheLeePiper
Question regarding the ComboDropDown function. I have set up a cell as a DropDown with the Cue working great. If I click the body of the cell, it properly drops the list, and grid.Row correctly is the current grid row of the DropDown cell. However, if I drop the list using the button itself, grid.Row is the previously entered grid row (and not the DropDown grid row). Is this the expected behavior? (Also note that the ValidateEdit function is also subsequently fired with the correct grid.Row in both cases.)
Additionally, if I click on the list item that is the current ComboListIndex, neither of these evens are fired. For example, say I have a list A & B, and A was previously selected. If I select A again, the events are not fired. If I select B, they are fired. Expected behavior? (This is less of an issue because data doesn't change, but it is curious that the events didn't fire.)
Thanks!
Yes, grid.Row is the current focused cell. If you click the combo cue, the focus doesn't change. So, you might use the grid.EditRow function.
The ValidateEdit event is fired only when the text has changed, that's by design. It's an event to validate changes.
You might check the LeaveEdit or AfterEdit event if that fits your needs.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Included the Copy/Cut/Paste/Delete method. This is just a simple wrapper to put .Clip property to the clipboard or set the .Clip property from the clipboard.
Also included the ClipCopyMode property. 0 - Normal and 1 - IncludeFixedRows for the moment only.
This value affects the Copy method and the Clip Get-Property. (not the Clip Let-Property)
To have Clip Get/Let property to behave the same keep it as 0 - Normal. (default)
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
I need in one of my projects to write normal text and bold text within the same grid cell, or texts of different colors. Does your Vbflexgrid allow it?
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
No it does not support in-cell markup.
All font styles apply to the complete cell.
-
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
Update released.
Included the ClipSeparatorCol/ClipSeparatorRow run-time property.
These properties expose the default separators vbTab and vbCr. Thus the defaults can be changed.
Also, it provides a way to support more than 1 character for a separator.
This may be useful for the row separator vbCrLf to better exchange with MS Excel.
However, for back-compatibility. If the ClipSeparators property is set, then that will be used.
But that is consistent, if ClipSeparators is empty the defaults are used. (ClipSeparatorCol/ClipSeparatorRow)
ClipSeparators is just limited to 1 character per separator.
So, during a Form_Load one can change the default value:
Code:
VBFlexGrid1.ClipSeparatorRow = vbCrLf