Print Page | Close Window

BUG: Ctrl+Click

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=11040
Printed Date: 04 May 2024 at 8:21am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: BUG: Ctrl+Click
Posted By: jpbro
Subject: BUG: Ctrl+Click
Date Posted: 15 June 2008 at 3:32pm
I have a ReportControl with these settings:


   With Me.ReportControl1
      .AllowColumnRemove = False
      .AllowColumnReorder = False
      .AllowColumnResize = False
      .AllowColumnSort = True
      .AllowEdit = False
      .AutoColumnSizing = True
      .MultipleSelection = False
      .MultiSelectionMode = False
      .PreviewMode = True
      .SelectionEnable = True
      .ShowRowFocus = False
    End With


The ReportControl has 2 records, and if the user presses Ctrl+Click on either record, the entire selection disappears (that is, no rows appear selected). I would think that the clicked row should be selected regardless of whether Ctrl is held when an item is clicked or not.

Thanks.


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

Language: Visual Basic 6.0 SP6




Replies:
Posted By: Smucker
Date Posted: 15 June 2008 at 3:55pm
I'm not very familiar with the report control, but Windows guidelines for extended selections cause Ctrl+Click to add or remove the clicked item from the list of selected items. It doesn't sound like this is happening.



Posted By: jpbro
Date Posted: 15 June 2008 at 4:19pm
Hi Smucker,

Thanks for the reply...I would expect this too happen if the MultipleSelection property was True, since then adding and removing items by Ctrl+Click would be required. With MultipleSelection=False, I expected the ReportControl to leave at least one item selected at all times (this is how the ListBox appears to behave in single selection mode), but perhaps I need to enforce this behaviour myself.

Here's a workaround:


Private mlngReportControlMouseX As Long
private mlngReportControlMouseY As Long

Private Sub ReportControl1_MouseMove(Button As Integer, Shift As Integer, x As Long, y As Long)
   mlngReportControlMouseX = x
   mlngReportControlMouseY = y
End Sub

Private Sub ReportControl1_SelectionChanged()
   Dim objHT As ReportHitTestInfo
  
   If Me.ReportControl1.SelectedRows.Count = 0 Then
      Set objHT = Me.ReportControl1.HitTest(mlngReportControlMouseX, mlngReportControlMouseY)
      If Not objHT Is Nothing Then
         If Not objHT.Row Is Nothing Then
            Me.ReportControl1.Rows(objHT.Row.Index).Selected = True
         End If
      End If
   End If
End Sub


I tried a couple of other workarounds that I thought would be cleaner, but they failed for different reason. For example, recording only the Hit row in the MouseDown event when Ctrl has been pressed failed because it seems that SelectionChanged fires before MouseDown (strangely enough). A better method might be to use the GetCursorPos API to encapsulate all the logic in the SelectionChanged event.

I've only just started using the ReportControl, and I'm surprised to see no SelectionChanging event (or BeforeSelectionChanged) with the ability to cancel the change...It would have been useful in this case (and in others that I can imagine).


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

Language: Visual Basic 6.0 SP6



Posted By: wlcabral
Date Posted: 16 June 2008 at 11:46am

I´m using this code (MS FOXPRO) in MouseUp Event :

 

With xTremeReportControl

If NOT .multipleSelection

oItem = .FocusedRow

If !Isnull(oItem)

oItem.Selected = True

endif

endif

endwith

 



-------------
wlcabral


Posted By: jpbro
Date Posted: 28 June 2008 at 10:21pm
Hi wlcabral...Sorry I must have missed your post earlier. Thanks a lot for this trimmed down solution, it is very useful!

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

Language: Visual Basic 6.0 SP6




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net