Hi I have a base form that subsequent forms are inherited from. It is a form that is designed to have an appropriate look and feel and really doesn't do anything else. The other froms just inherit it as per:

public partial class frmLoad : frmPeakBase

The only other thing that I have done on the frmPeakBase is the following:

public partial class frmPeakBase : Form
    {
        public PPCustomMessageBox.Question PQ = new PPCustomMessageBox.Question();
        public frmPeakBase()
        {
            InitializeComponent();
        }
    }

Which just creates a reference to a custom message box.
The problem that I am facing is that every time that I load a form that is inherited from the frmPeakBase the message box automatically starts and you have to Alt f4 to close it. This is when it is still in design mode within VS. Any ideas?

Thanks

--Taylby

Recommended Answers

All 3 Replies

have you set a breakpoint to see what is happening..you can then step through the code with f11..

something is obviously being run somewhere whenever you load your form...

post more code so we can see what is happening..

Hi James, thanks for your reply but that's the problem. Although it does happen when I run my code it is also when I am working in Visual studio. So for example when I open up the solution and click on one of the forms that inherits frmBase to work on in the designer it will automatically display the pop up. I was thinking that I had inadvertently had a line with showDialogue(); in the constructor but this isn't happening either. Here is my code for the message box it just returns a bool; I am sure you can work out its functionality.

public partial class Question : Form
    {
       public bool QuestionValue;
        public Question()
        {
            InitializeComponent();
        }

        public bool LoadQuestionBox(string Title, string Question)
        {
            this.Text = Title;
            lblQuestionText.Text = Question;
            ShowDialog();
            return QuestionValue;
        }

        private void btnYes_Click(object sender, EventArgs e)
        {
        QuestionValue = true;
        this.Close();
        //Question_FormClosing();
        }

        private void btnNo_Click(object sender, EventArgs e)
        {
            QuestionValue = false;
            this.Close();
        }

        
    }

--Taylby

Ok, just in case any one wanted to know the solution or the cause it was this:

public PPCustomMessageBox.Question PQ = new PPCustomMessageBox.Question();

it should be more like this:

PPCustomMessageBox.Question PQ;

Basically it was trying to create a new instance of its self when ever it rendered the form in the designer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.