This is a migrated thread and some comments may be shown as answers.

Button disabling on panel visibility event

5 Answers 425 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Peter Turner
Top achievements
Rank 1
Peter Turner asked on 29 Jun 2011, 04:23 PM
i have an app that has a RadWizard component on a tab.  the wizard deals with device interaction and connectivity.  on certain pages (panels) i need to check for certain states of the device.  dependent on the results of the state checks, i need to disable/enable the back/next/cancel buttons.  what i have set up is to "catch" the panel visibility changed event.  if the panel is visible, i do the checks, and possibly disable the next button - as well as other elements on the panel.  the other elements on the panel are disabled/enabled correctly, but the back/next/cancel buttons are still enabled.  i've stepped thru the debugger and verified that the Next Button is disabled, but it appears that there is a "higher" event that is re-enabling the button.enabled properties.  on some panels, i have actions that are controlled by "action" buttons (move, measure, set, etc.) and they disable/enable the buttons, and this works.

is the VisibilityChanged event the correct one for what i'm trying to do?  if not, how can i achieve this?

is this a bug for the control?

thanks,

pete.

5 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 04 Jul 2011, 02:42 PM
Hello Peter,

I am not able to reproduce the issue you report. Setting the Enabled state of the RadWizard buttons should enable/disable them. For example, you can disable the CancelButton of the control using:
this.radWizard1.CancelButton.Enabled = false;

For your case, I would suggest you to use the SelectedPageChanged event of RadWizard to enable/disable the control buttons depending on your conditions:
private void radWizard1_SelectedPageChanged(object sender, Telerik.WinControls.UI.SelectedPageChangedEventArgs e)
{
    if (e.SelectedPage == this.radWizard1.Pages[1])
    {
        this.radWizard1.CancelButton.Enabled = false;
    }
    else
    {
        this.radWizard1.CancelButton.Enabled = true;
    }
}

I hope it helps.

Best regards,
Alexander
the Telerik team
Registration for Q2 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting July 18th and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Peter Turner
Top achievements
Rank 1
answered on 05 Jul 2011, 04:01 PM
Thanks, Alexander.

i have 4 RadWizard controls on a TabControl.  each RadWizard has multiple pages (8+).  if go to say, the 4th panel on the 1st control, and add a VisibilityChanged event handler where i enable/disable the next button (or back/cancel), running in the VS 2010 debugger, i can see that the property is changed to the state i set, but continuing on, the "visible" button is never disabled.  i'm thinking that some other aspect of the RadWizard control is re-enabling it.  i have set breakpoints in all my code where the next button is enabled, and these are never hit.  note: after the page has "settled" and i perform an action on the page, the buttons are enabled/disabled as i would expect - under "my" functional control.

i'm in the process of changing over to trying the SelectedPageChanged event on the RadWizard itself.  the disadvantage with this approach is that i must know what the index of the pages is.  should i re-order the pages, i'd have to change the index reference in the handler.

pete.

update: 070511-1411 ... the SelectedPageChanged event processing does enable/disable the button as expected.
0
Alexander
Telerik team
answered on 08 Jul 2011, 11:03 AM
Hello Peter,

I am glad to hear your solution works as expected now.

When using SelectedPageChanged event, it is not necessary to know the index of the page as you can use the instance of the page which the designer of the control creates. It is similar to your previous approach of using the created panels.

Best regards,
Alexander
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Peter Turner
Top achievements
Rank 1
answered on 11 Jul 2011, 02:29 PM
hi Alexander,

i was simply using the example you posted, which used an index into the pages.  what would the non-indexed "method" look like?

thanks,

pete.
0
Alexander
Telerik team
answered on 14 Jul 2011, 11:29 AM
Hello Peter,

When you drag RadWizard from the Toolbox and drop it on your form, you can find serialized in your designer generated code the control's initially created pages:
private Telerik.WinControls.UI.WizardCompletionPage wizardCompletionPage1;
private Telerik.WinControls.UI.WizardWelcomePage wizardWelcomePage1;
private Telerik.WinControls.UI.WizardPage wizardPage1;

These pages are added to the Pages collection of RadWizard. Adding a new page will include it in the designer generated code as well:
private Telerik.WinControls.UI.WizardPage wizardPage2;

You can use these page instances in the code snippet I gave earlier in this forum thread:
if (e.SelectedPage == this.wizardPage1)

Best regards,
Alexander
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Wizard
Asked by
Peter Turner
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Peter Turner
Top achievements
Rank 1
Share this question
or