Re: [2008][UPDATE, Aero Glass] Wizard Template UserControl - Full Design-time support
Thanks for the fast reply. I've checked, where this error exactly occurs:
1. Setting a breakpoint on Me.Close()
2. It jumps into this sub:
Code:
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Dim i As Integer = Me.Pages.Count - 1
RaiseEvent NextButton_Clicked(CType(Me.Pages(Me.SelectedIndex), WizardPage).IsLastPage)
If Me.SelectedIndex < i Then
Me.SelectedIndex += 1
End If
End Sub
3. SelectedIndex is -1 when jumping into above sub
4. the sub sets it to +1 = 0
5. and the error occurs in the Property:
Code:
Public Property SelectedIndex() As Int32
Get
Return Me.Pages.IndexOf(CType(Me.SelectedPage, WizardPage))
End Get
Set(ByVal Value As Int32)
If Value = -1 Then
Me.SelectedPage = Nothing
Else
Me.SelectedPage = DirectCast(Me.Pages(Value), WizardPage)
End If
End Set
End Property
on this line
Code:
Me.SelectedPage = DirectCast(Me.Pages(Value), WizardPage)
It seems the inital error is in the btnNext_Click-Sub, because there the SelectedIndex is set to a wrong value.
Re: [2008][UPDATE, Aero Glass] Wizard Template UserControl - Full Design-time support
Ok, thanks. It seems the pages are being disposed from the form once you run the Close call. This happens in the RaiseEvent call from your first code snippet. After that, it sets the SelectedIndex to the next page, but only if there is a next page.
The error is that this "is there a next page?" check is done before the RaiseEvent and thus before all pages are removed. Before the RaiseEvent, i = the number of pages - 1. If nothing happens with the page count in the NextButton_Click event, i doesn't change. But in this case, the page count changes and i is outdated. I think simply moving the assignment of i to behind the RaiseEvent call would fix it:
Code:
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
RaiseEvent NextButton_Clicked(CType(Me.Pages(Me.SelectedIndex), WizardPage).IsLastPage)
Dim i As Integer = Me.Pages.Count - 1
If Me.SelectedIndex < i Then
Me.SelectedIndex += 1
End If
End Sub
Re: [2008][UPDATE, Aero Glass] Wizard Template UserControl - Full Design-time support
That's it.
Now it closes without any errors.
Btw. how you want to be mentioned in a released program? a line in the About-Dialog? :D
Re: [2008][UPDATE, Aero Glass] Wizard Template UserControl - Full Design-time support
Whatever you want is fine by me :)