Adding Buttons to Wizard dynamically breaks layout

Wizard for Windows Forms Forum

The latest build of this product (v22.1.2) was released 3 months ago, which was before this thread was created.
Posted 17 days ago by Matthias Hess
Version: 20.1.1
Platform: .NET 4.8
Environment: Windows 10 (64-bit)
Avatar

Hello there

I hope you can help us with this pesky problem. We are using version 20.1.403.0 of Actipro Wizard. If we need to upgrade to a newer version to fix the issue, please let me know.

Problem:

We are trying to add controls dynamically to WizardPages at runtime. This breaks the layout of the pages so that the controls are moved over the header of the InnerPage.

We want our Wizard to look like this

Instead it looks like this

How to reproduce the problem:

You should be able to reproduce the problem easily with the following code snippet:

namespace WindowsFormsApp1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            ActiproSoftware.Products.ActiproLicenseManager.RegisterLicense(@"CM Informatik AG", @"XXXX-XXXX-XXXX-XXXX-XXXX");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new TestWizard());
        }
    }
    
    public class TestWizard: WizardDialogForm
    {
        public TestWizard()
        {
            this.Wizard.Pages.Add(new TestPage());
            
        }
    }

    public class TestPage : WizardPage
    {
        public TestPage()
        {
            AddButton();
           
        }

        private void AddButton()
        {
            Button b = new Button();
            b.Text = "Click me, try resizing the form to fix layout";
            b.Dock = DockStyle.Top;
            b.Click += BOnClick;
            this.Controls.Add(b);
        }

        private void BOnClick(object sender, EventArgs e)
        {
            AddButton();
        }
    }
}

Best Regards

Matthias Hess
CM Informatik AG

Comments (1)

Posted 16 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Matthias,

Thank you for the sample code and the screenshots. Those are always a great help!

I was able to reproduce the issue in v21.1.0, but not in v21.1.1.  We fixed a scenario in v21.1.1 that was causing what you are seeing. Once I moved the sample code to target v21.1.1 or higher, the initial Wizard layout was correct and continued to display correctly as I added more buttons.

Unfortunately, the solution here will require upgrading to at least v21.1.1.

As a tip... we starting publishing NuGet packages with v21.1.0, so you could also use this time to switch to NuGet and make it easier to target specific versions like this. The following link has more details about working with NuGet:

https://www.actiprosoftware.com/docs/controls/winforms/nuget

Please reach out if moving to the newer release does not fully resolve the issue you are seeing.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.