StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



How to use the ListView Grouping?Expand / Collapse
Author
Message
Posted 06/07/2008 11:33:26 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:02:02 PM
Posts: 471, Visits: 2,015
Hi Trent,

I saw this listview from one of your videos and now I have the need to incorporate this grouping feature in one of my listview.

I looked in the forum and the help file and could not find any info about how to do this.  Could you please post some sample code on how to accomplish this grouping display in the listview?

Edhy Rijo
Progytech (Computer Consultants)
Post #16899
Posted 06/09/2008 8:13:23 AM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 3:44:43 PM
Posts: 627, Visits: 10,881
Hey Edhy.

Just to get you going, use your ListView RowPopulating Event to set e.UseGroup to True. Then you set the e.GroupHeaderText to the Group you want and it should work. Something like:

    Private Sub MyListView_RowPopulating(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs) _
      Handles MyListView.RowPopulating

        With CType(e.BusinessObject, MyBO)
            '-- Set Columns
            e.Values(0).DisplayValue = Something
            e.Values(1).DisplayValue = SomethingElse

            e.UseGroup = True

            Select Case .myField
                Case SomeCondition1
                    e.GroupHeaderText = "Group1"

                    '-- here you can even set an image, for example from a ImageListControl
                    e.ImageIndex = 1

                Case SomeCondition2
                    e.GroupHeaderText = "Group2"
                    e.ImageIndex = 2

                Case SomeCondition3
                    e.GroupHeaderText = "Group3"
                    e.ImageIndex = 3

                Case SomeCondition4
                    e.GroupHeaderText = "Group4"
                    e.ImageIndex = 4

                Case Else
                    e.GroupHeaderText = "Not Defined"
                    e.ImageIndex = 5
            End Select

        End With
    End Sub

Post #16905
Posted 06/09/2008 8:18:39 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:02:02 PM
Posts: 471, Visits: 2,015
Hi Ivan,
Thanks, that will get me going, will try now.

Edhy Rijo
Progytech (Computer Consultants)
Post #16907
Posted 06/09/2008 9:12:50 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:02:02 PM
Posts: 471, Visits: 2,015
Ok, I have the group showing, but since this method is executing per row, how do I filter the rows to show in the correct group? so the records for group 1 will be show under group 1 and the records for group 2 will be shown in group 2 and so on.

Edhy Rijo
Progytech (Computer Consultants)
Post #16909
Posted 06/09/2008 9:56:13 AM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 3:44:43 PM
Posts: 627, Visits: 10,881
Have you tried sorting the contents of your BO on the column you are using for grouping?
Post #16913
Posted 06/09/2008 9:57:49 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 5:44:29 PM
Posts: 4,366, Visits: 4,393
I don't understand your question, but the the rows are grouped based on the GroupHeaderText.  When you set the e.GroupHeaderText value, any row that has the same text will appear in the same group.  That is it...not anything more to it.  Also, if you eve set the e.UseGroup to False, this gets set for the entire grid, not a per item basis.  But it still needs to be set within this method in order to take action.

So if you are trying to sort, you could include this as part of a BO sort or part of a query sort.  Hope that makes sense.

Post #16914
Posted 06/09/2008 11:02:19 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:02:02 PM
Posts: 471, Visits: 2,015
Trent L. Taylor (06/09/2008)
When you set the e.GroupHeaderText value, any row that has the same text will appear in the same group. That is it...not anything more to it.
So if you are trying to sort, you could include this as part of a BO sort or part of a query sort. Hope that makes sense.


Trent, Ivan,
That was it, having the proper ORDER BY in the fill method of the BO and just setting the GroupHeaderText to a value that is part of the row will do the trick. This is my code:

Private Sub lvPaymentSchedule_RowPopulating(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs) Handles lvPaymentSchedule.RowPopulating
Dim loBO As PaymentScheduleBO
loBO = e.BusinessObject
e.UseGroup = True
e.GroupHeaderText = "Vehicle Group " & loBO.FK_Vehicle.ToString
End Sub


Thanks you both!


Edhy Rijo
Progytech (Computer Consultants)
Post #16922
Posted 06/09/2008 2:06:06 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 3:44:43 PM
Posts: 627, Visits: 10,881
Glad it helped, Edhy.
Post #16927
Posted 06/09/2008 3:13:44 PM