Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Suppress SelectionChanged Event
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Suppress SelectionChanged Event

 Post Reply Post Reply
Author
Message
haraldradi View Drop Down
Newbie
Newbie


Joined: 31 August 2006
Location: Austria
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote haraldradi Quote  Post ReplyReply Direct Link To This Post Topic: Suppress SelectionChanged Event
    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.
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
haraldradi View Drop Down
Newbie
Newbie


Joined: 31 August 2006
Location: Austria
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote haraldradi Quote  Post ReplyReply Direct Link To This Post 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?)
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
haraldradi View Drop Down
Newbie
Newbie


Joined: 31 August 2006
Location: Austria
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote haraldradi Quote  Post ReplyReply Direct Link To This Post Posted: 07 February 2007 at 5:26pm
any news on that?
Back to Top
haraldradi View Drop Down
Newbie
Newbie


Joined: 31 August 2006
Location: Austria
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote haraldradi Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
carson View Drop Down
Newbie
Newbie


Joined: 06 September 2007
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote carson Quote  Post ReplyReply Direct Link To This Post 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
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.157 seconds.