![]()  | 
 
RESOLVED: Group By Clicked Column | 
 
    Post Reply  
   | 
  
| Author | |
   
   JasonG  
   
   Groupie  
   Joined: 07 July 2008 Status: Offline Points: 76  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Topic: RESOLVED: Group By Clicked ColumnPosted: 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  | 
 |
![]()  | 
 |
   
   jpbro  
   
   Senior Member  
   Joined: 12 January 2007 Status: Offline Points: 1357  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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: 
  | 
 |
| 
   
     
     Product: Xtreme SuitePro (ActiveX) version 16.2.6 
   
  Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6  | 
 |
![]()  | 
 |
   
   jpbro  
   
   Senior Member  
   Joined: 12 January 2007 Status: Offline Points: 1357  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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: 
   
  
  | 
 |
| 
   
     
     Product: Xtreme SuitePro (ActiveX) version 16.2.6 
   
  Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6  | 
 |
![]()  | 
 |
   
   JasonG  
   
   Groupie  
   Joined: 07 July 2008 Status: Offline Points: 76  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 08 July 2008 at 2:06pm | 
 
| 
   
    
   Very nice. Thank you!!
    
   
   | 
 |
![]()  | 
 |
    Post Reply  
   | 
  |
|       
  
  Tweet   	
    | 
 
| Forum Jump | Forum Permissions  ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum  |