Print Page | Close Window

Suppress SelectionChanged Event

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=4932
Printed Date: 20 September 2024 at 2:40am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Suppress SelectionChanged Event
Posted By: haraldradi
Subject: Suppress SelectionChanged Event
Date Posted: 31 August 2006 at 5:40am
What is the recommended way to intercept a selection change and suppress the SelectionChanged Event?
I want some kind of "All changes will be lost - Proceed?" alert box which forces the selection to stay unmodified if canceled.



Replies:
Posted By: sserge
Date Posted: 31 August 2006 at 9:21am
Hi,

Unfortunately, no recommended way because SelectionChanged event just  notifies user about upcoming selection change.

For now I can only recommend having a custom selected rows collection (mark items, for example, by adding a special invisible boolean field to your Record object). Then ask your alert on SelectionChanged event, if necessary use wndReportControl.SelectedRows.DeleteAll and add your items into SelectedRows collection... (one more hint - you can find a Row by Record using .Rows.FindRow method)

--
WBR,
Serge


Posted By: haraldradi
Date Posted: 01 September 2006 at 2:04am
Your recommendation is not really feasible as the SelectionChanged event is fired _after_ selecting the new and modifying the SelectedRows collection inside the event handler would fire yet another SelectionChanged event recursively.
So your solution would imply adding some ugly code to prevent this recursive SelectionChanged firing - which i could live with - but also produces a flickering selection in the report control.

I'd prefer to see an additional BeforeSelectionChanged or SelectionChanging event which can be trapped to control the selection behaviour of the report control.

regards,
harald

(PS: does it make any difference if i file this as a feature request?)


Posted By: sserge
Date Posted: 01 September 2006 at 6:59am
Ok, agree with you that adding SelectionChanging event would work much better for you. I'll consider this post as a feature request.

--
WBR,
Serge


Posted By: haraldradi
Date Posted: 07 February 2007 at 5:26pm
any news on that?


Posted By: haraldradi
Date Posted: 08 February 2007 at 2:44am
i have noticed the new SelectionChanging event on the shortcut bar, the same thing for the report control would be fine.


Posted By: carson
Date Posted: 06 September 2007 at 4:34pm
I too have a need for that event. Seeing the time of your original post and now, it doesn't look good as a feature request, so, I'll tell you my fix.
When presented with these types of problems, I usually try to reach into the Desaware Spyworks ActiveX controls which are invaluable to me. You can do this through VB subclassing, but this example is easier. I simply subclass the Report Control like and do this in the capture event.
 
Private Sub SubClass1_WndMessage(hwnd As Long, msg As Long, wp As Long, lp As Long, retval As Long, nodef As Integer)
  CONST WM_NOTIFY = &H4E
  CONST WM_PARENTNOTIFY = &H210
  Select Case msg
  Case WM_NOTIFY
    if lp = 1568236 then
      If SubClass1.Tag = "CANCEL" Then
       ' This cancels this message
        nodef = True
        retval = 1
      End If
      SubClass1.Tag = ""
    End if
  Case WM_PARENTNOTIFY
    Dim RptInfo As ReportHitTestInfo
    Set RptInfo = wndReportControl.HitTest(LowWord(lp), HighWord(lp))
    If RptInfo.ht = xtpHitTestReportArea Then
      SubClass1.Tag = ""
      'If Conditions are met then SubClass1.Tag = "CANCEL"
    End If
  End Select
End Sub
Function HighWord%(DWord&)
  HighWord% = (DWord And &HFFFF0000) \ &H10000
End Function
Function LowWord%(DWord&)
  If DWord And &H8000& Then ' &H8000& = &H00008000
    LowWord% = DWord Or &HFFFF0000
  Else
    LowWord% = DWord And &HFFFF&
  End If
End Function



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