Re: AfterGroupChange Event and its parameters
SharpGrid Support
AfterGroupChange Event and its parameters
03-13-2009, 9:42 AM
Hello guys,
I have a small problem:
When I want to group my records on a columnheader, which isnt the first one, the AfterGroupChange parameter GroupOrColIndex just gives me the first column, not the column, which I want to group with.
I attached some screenshots, its in german, but it doesnt matter what the meaning is. The value on the messagebox is the caption of the column-header, which I print out with the
GroupOrColIndex value.
I hope you see what I mean.
best regards
Müller Matthias
Re: AfterGroupChange Event and its parameters
03-16-2009, 5:10 AM
DrMueller,
Please note that in AfterGroupChange event
:
If Operation is set to sgGroupRemove, GroupOrColIndex is the index of the dragged column.
If Operation is set to sgGroupAdd or sgGroupMove, GroupOrColIndex is the index of the dragged group.
So, in your case you are getting the index of a group, not column.
Thank you,
Andrey T.
Re: AfterGroupChange Event and its parameters
03-16-2009, 6:39 AM
So how do make it working, that the grid groups at the right column?
I looked at all events, but I cant find another one, which helps me at this situation.
Best regards
Müller Matthoas
Re: AfterGroupChange Event and its parameters
03-17-2009, 5:40 AM
DrMueller,
Could you give me please step by step details what are you trying to do? You can add group by dragging required column to group box or using Groups.Add method where you specify Column Key as parameter.
Thank you,
Andrey T.
Re: AfterGroupChange Event and its parameters
03-23-2009, 5:25 AM
Ok lets try step by step:
1. User clicks on one header.
2. User drops it to the grouping field.
3. all records should get grouped by this field.
But this doesnt happen, it just groups by anything.
Now I made this:
Private Sub sgSchnellErfassung_AfterGroupChange(ByVal Operation As DDSharpGridOLEDB2.sgGroupOperation, ByVal GroupOrColIndex As Long)
sgSchnellErfassung.Columns(iNewGroupIndex).SortOrder = sgSortAscending
End Sub
Private Sub sgSchnellErfassung_BeforeGroupChange(ByVal Operation As DDSharpGridOLEDB2.sgGroupOperation, ByVal GroupOrColIndex As Long, ByVal NewIndex As Long, SortOrder As DDSharpGridOLEDB2.sgSortOrder, SortType As DDSharpGridOLEDB2.sgSortType, ShowFooter As Boolean, cancel As Boolean)
iNewGroupIndex = GroupOrColIndex
End Sub
I take the groupIndex in the beforeGroupChange-sub and take it in the AfterGroupChange, but this doesnt work too.
I hope you see the problem now.
Re: AfterGroupChange Event and its parameters
03-23-2009, 7:15 AM
DrMueller,
Thank you for additional description, now, I think, I can see your problem; your #Grid items are not sorted by grouping column. To overcome this you can use the following workarounds:
Private Sub SGGrid1_BeforeGroupChange(...)
If Operation = sgGroupAdd Then
SGGrid1.Sort -1, -1, SGGrid1.Columns(GroupOrColIndex).Key, _
sgSortAscending, sgSortTypeString
End If
End Sub
Private Sub SGGrid1_BeforeGroupChange(...)
If Operation = sgGroupAdd Then
SortOrder = sgSortAscending
End If
End Sub
Thank you,
Andrey T.
Re: AfterGroupChange Event and its parameters
03-25-2009, 2:30 AM
Yes thats it.
Thanks alot