Suppress SelectionChanged Event |
Post Reply |
Author | |
haraldradi
Newbie Joined: 31 August 2006 Location: Austria Status: Offline Points: 12 |
Post Options
Thanks(0)
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. |
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
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 |
|
haraldradi
Newbie Joined: 31 August 2006 Location: Austria Status: Offline Points: 12 |
Post Options
Thanks(0)
|
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?) |
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
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 |
|
haraldradi
Newbie Joined: 31 August 2006 Location: Austria Status: Offline Points: 12 |
Post Options
Thanks(0)
|
any news on that?
|
|
haraldradi
Newbie Joined: 31 August 2006 Location: Austria Status: Offline Points: 12 |
Post Options
Thanks(0)
|
i have noticed the new SelectionChanging event on the shortcut bar, the same thing for the report control would be fine.
|
|
carson
Newbie Joined: 06 September 2007 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
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 |
|
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 |