Button disabling on panel visibility event

6 posts, 0 answers
  1. Peter Turner
    Peter Turner avatar
    5 posts
    Member since:
    Apr 2010

    Posted 29 Jun 2011 Link to this post

    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.
  2. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 04 Jul 2011 Link to this post

    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!
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter Turner
    Peter Turner avatar
    5 posts
    Member since:
    Apr 2010

    Posted 05 Jul 2011 Link to this post

    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.
  5. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 08 Jul 2011 Link to this post

    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!

  6. Peter Turner
    Peter Turner avatar
    5 posts
    Member since:
    Apr 2010

    Posted 11 Jul 2011 Link to this post

    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.
  7. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 14 Jul 2011 Link to this post

    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!

Back to Top
UI for WinForms is Visual Studio 2017 Ready