Active Smart Part Changed

Topics: CAB & Smart Client Software Factory
May 23, 2007 at 1:17 PM
I am implementing a project utilising the CAB framework.
I use the following code to show a new View:

RoleManager roleManagerView = WorkItem.SmartParts.AddNew<RoleManager>();

When the above code is called the current view is replaced by the above.
I would like to be able to notify the current smart part that a new part is about to be displayed. I can then check if any changes have been made.
If not I can offer the user the chance to save the changes first or cancel the loading of the new part.
I could probably acheive this by explicitly closing the current part before adding the new one and overriding the closing method on the part, but is there a way without having to explicitly close the part first.
May 23, 2007 at 1:42 PM
Edited May 23, 2007 at 1:45 PM
You can handle the SmartPartActivated event of your workspace like so

Sub RightWorkspace_SmartPartActivated(ByVal sender As Object, ByVal e As Microsoft.Practices.CompositeUI.SmartParts.WorkspaceEventArgs) Handles RightWorkspace.SmartPartActivated

'put your code here

End Sub

this event if fired whenever a smartpart is activated to be shown on the workspace.