Designer throwing up an error!

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2010-04-21T11:37:02Z Indexed on 2010/04/21 11:43 UTC
Read the original article Hit count: 323

Filed under:

I have a dropdown list that I want to show only certain options when a bool is true of false.

if (mainForm.boolEdit == true)
        {
            this.cmbStatusBox.Items.AddRange(new object[] {
            "Cooking",
            "In-transit",
            "Delivered"});
        }
        else
        {
            this.cmbStatusBox.Items.AddRange(new object[] {
            "Ordered"});
        }

I put this code into the saveForm.Designer.cs and got the following error:

The designer cannot process the code at line 205:

if (mainForm.boolEdit == true) { this.cmbStatusBox.Items.AddRange(new object[] { "Cooking", "In-transit", "Delivered"}); } else { this.cmbStatusBox.Items.AddRange(new object[] { "Ordered"}); }

The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again.

What are my alternatives?

© Stack Overflow or respective owner

Related posts about c#