SelectionChanging vs SelectionChanged events

Wizard for Windows Forms Forum

Posted 13 years ago by Richard Bysouth
Avatar
Hi

In my wizard page-handling code I have been using the SelectionChanging event to control the setting up of the next wizard page according to previous selections. This includes setting the visibility of certain controls. However, I have noticed that while in this event, all controls on the new wizard page are visible=false.

Am I supposed to be using the SelectionChanged event for code that initialises a page? One of the reasons I've been using SelectionChanging is because I don't want the code to be executed if navigating backwards through pages, so have used something like "If e.Reason = ActiproSoftware.Wizard.WizardPageEventReason.BackButtonClick Then Exit Sub".

I have tried calling the page initialisation code from SelectionChanged but have noticed there is a lot of flicker from the controls (have tried using SuspendLayout on the wizard page with no difference).

Ideally, I'd like to leave the page initialisation code in SelectionChanging, however I still need to ensure controls are visible according to previous selections.

A sample of my code:


    Private Sub wizWizard_SelectionChanging(ByVal sender As Object, ByVal e As ActiproSoftware.Wizard.WizardPageCancelEventArgs) Handles wizWizard.SelectionChanging

        If e.Reason = ActiproSoftware.Wizard.WizardPageEventReason.BackButtonClick Then Exit Sub

            'set up the controls on the new step in the wizard
            Select Case wizWizard.SelectedPage.Name

                Case wpReportingOptions.Name

                    SetupReportingOptionsPage()
                'other cases removed

            End select

    End Sub

Private Sub SetupReportingOptionsPage()

      'set control visibility according to options selected on previous pages
      lblDescription.Visible = someValueOnPreviousPage

      'TODO: the setting of the above value is ignored here
      'something to do with the wizard page not being initialised yet

end sub

Thanks

Richard

[Modified at 05/09/2006 12:31 AM]

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Richard,

The Control.Visible property might be programmed by Microsoft to look at
the parent control's visibility as well, which could be causing what's
happening in your scenario. I'd recommend using separate variables to track
the visibility instead to work around that issue with the .NET framework.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.