Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening a dialog after closing an OpenFileDialog #46

Open
axx0 opened this issue Dec 24, 2022 · 0 comments
Open

Opening a dialog after closing an OpenFileDialog #46

axx0 opened this issue Dec 24, 2022 · 0 comments
Labels
bug Something doesn't function as intended

Comments

@axx0
Copy link

axx0 commented Dec 24, 2022

So, I wish to:

  1. Open an OpenFileDialog
  2. After closing the OpenFileDialog immediately open another custom dialog

Here is my code:

using Modern.Forms;
using System.Drawing;

namespace ModernFormsApp1
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            this.Shown += async (_, _) =>
            {
                var ofd1 = new OpenFileDialog
                {
                    Title = "Open this file 1"
                };
                await ofd1.ShowDialog(this);

                await new DialogForm().ShowDialog(this);
            };
        }
    }

    public class DialogForm : Form
    {
        public DialogForm()
        {
            Text = "Dialog Form";
            Size = new Size(500, 250);

            var button3 = Controls.Add(new Button
            {
                Text = "DialogResult.Abort button",
                Left = 10,
                Top = 124,
                Width = 250,
                DialogResult = DialogResult.Abort
            });

            var button4 = Controls.Add(new Button
            {
                Text = "DialogResult.None button",
                Left = 10,
                Top = 164,
                Width = 250,
                DialogResult = DialogResult.None
            });
        }
    }
}

When I run the code the OpenFileDialog is opened, but when I close it I get a blank dialog screen:
image

However when I change the order of dialogs (first opening the custom dialog and then the OpenFileDialog) it runs ok.

What am I doing wrong?

@jpobst jpobst added the bug Something doesn't function as intended label May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something doesn't function as intended
Projects
None yet
Development

No branches or pull requests

2 participants