Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - RESOLVED: Group By Clicked Column
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

RESOLVED: Group By Clicked Column

 Post Reply Post Reply
Author
Message
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Topic: RESOLVED: Group By Clicked Column
    Posted: 08 July 2008 at 1:45pm
I am looking for some code that will sort AND group the report by the column clicked. When I initialize the form, I am setting a default grouping/sorting as shown here:

        Set Column = lstMessages.Columns.Add(3, "From", 130, True)
        Set C = Column
        Set Column = lstMessages.Columns.Add(4, "First", 90, True)
        Set Column = lstMessages.Columns.Add(5, "Last", 90, True)
        Set Column = lstMessages.Columns.Add(6, "fullmessage", 90, True)
        lstMessages.GroupsOrder.Add C



The current code I have is below, however the desired affect is not occurring. Only the sorting is taking place... The original grouping is not removed, nor is the new one added.

    Private Sub lstMessages_ColumnClick(ByVal Column As XtremeReportControl.IReportColumn)
        lstMessages.GroupsOrder.DeleteAll
        lstMessages.GroupsOrder.Add Column
        lstMessages.Populate
    End Sub

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 2:01pm
I have a solution, but it seems a little convoluted, so maybe there's a better way.

It appears the ColumnClick event doesn't fire when you click the header, but the SortOrderChanged event does. Problem is the SortOrderChanged event doesn't tell you what column was clicked, so you have to get the current cursor position, convert it to client coordinates and then get the column from the ReportControl HitTest method:


Private Type POINTAPI
   x As Long
   y As Long
End Type

Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32.dll" (ByVal hwnd As Long, ByRef lpPoint As POINTAPI) As Long

Private Sub ReportControl1_SortOrderChanged()
   Dim objHT As ReportHitTestInfo
   Dim udtCursor As POINTAPI

    With Me.ReportControl1
      GetCursorPos udtCursor
      ScreenToClient .hwnd, udtCursor
   
      Set objHT = .HitTest(udtCursor.x, udtCursor.y)
   
      If Not objHT Is Nothing Then
         If Not objHT.Column Is Nothing Then
            .GroupsOrder.DeleteAll
            .GroupsOrder.Add objHT.Column

            .Populate
         End If
      End If
     
   End With
End Sub

Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 2:04pm
There is a better solution...You can use the SortOrder object to get the first column in the Sort Order and skip the API & HitTest methods entirely:


Private Sub ReportControl1_SortOrderChanged()
    With Me.ReportControl1
      .GroupsOrder.DeleteAll
      .GroupsOrder.Add .SortOrder.Column(0)
     
      .Populate
   End With
End Sub

Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 2:06pm
Very nice. Thank you!!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.