Cancel OnFinishButtonClick() Event

Wizard for Windows Forms Forum

Posted 14 years ago by Rommel Edwards
Avatar
Hi there,

I've noticed that in the OnSelectionChanging() event we just need to set e.Cancel = True to stop the user from moving to another page. I've also noticed that there's no such facility in the OnFinishButtonClick() event. In the event that there is invalid data on the final page of the wizard, how do I stop a user from closing the wizard via the Finish button? (i.e cancelling the OnFinishButtonClicked event).

Thanks,
Rommel the iCeMAn.

Comments (8)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Rommel,

There is no need to have an e.Cancel in the Finish button event handler because that event handler is where you execute code like "this.Close();" to close a Form. If the data on the last page is invalid, simply don't execute your close code.


Actipro Software Support

Posted 14 years ago by Rommel Edwards
Avatar
Thanks for the reply,

It isn't that straight-forward though, which is the reason why I posted in the first place. You see, I don't have any code that explicitly states "Me.Close()". Actually, the event handler for the FinishButtonClick event is empty. In spite of this, if I click the Finish button at runtime, the wizard closes. This is not what I expected and it's why I am baffled.

Any ideas?
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ahh yes, I forgot to mention that. In a recent maintenance release we set up the Button to have a DialogResult.OK. We have written down to make that configurable for the next maintenance release. If you iterate through the Wizard control structure after the wizard loads, look for the Finish button and set its DialogResult to None. That will work around it for now until the next release.


Actipro Software Support

Posted 13 years ago by Rommel Edwards
Avatar
Hi,

I'm now revisiting this situation from where we left off, sorry about the extensive delay. You said to iterate through the control structure so I tried the following code:

Dim ctlTemp As Control

For Each ctlTemp In wizard.Controls

Next
The thing is, ctlTemp.Name always returns an empty string, and ctlTemp.GetType.ToString returns types such as "_9" and "_12". That's a dead-end for me.

Could you show me what you meant by iterating through the control structure to get at the Finish button?

Thanks.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Actually I believe the maint release with the fix for your problem is now available so no need to do this any more. Check out the release notes for the latest version.


Actipro Software Support

Posted 13 years ago by Rommel Edwards
Avatar
Ok,

I've been making life unneccessarily difficult :-) All I needed to do was to set Me.DialogResult = DialogResult.None to stop the wizard from closing during the OnFinishButtonClick() override.

Thanks for the input anyways :-)
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Anyhow in the latest release there is a new property for controlling what the Finish button's DialogResult is.


Actipro Software Support

Posted 13 years ago by Rommel Edwards
Avatar
Sorry, I didn't see your reply before I posted that last item. I'll check the new release, thanks again :-)
The latest build of this product (v2018.1 build 0341) was released 8 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.