1

I have seen a few questions about this but not one which is quite the same:

In Dev Studio 2017 I am writing a WinForms project.

At some point when I was coding I lost the ability to see the design view of the form.

See below, Form1 (the top one) only has the option to view the code, whereas Form2 has the ability to view the code or the design view.

Shift F7 has no effect and the Design View option does not appear in the right click menu.

enter image description here

How do I get the design view back?

3
  • 1
    Most likely due to AlertDetails type contained inside the same code file. Try moving it after Form1 code.
    – Ivan Stoev
    Sep 3, 2020 at 10:32
  • Double click on the main form icon. Right click is not used.
    – jdweng
    Sep 3, 2020 at 10:33
  • 1
    @IvanStoev, you are a king among men! If you put that as an answer I will accept it etc.
    – Stefan
    Sep 3, 2020 at 10:51

2 Answers 2

1

Design View option requires the code for the component to be designed to be either the only type, or first type inside the source code file.

In your case the code file contains a type AlertDetails which is before the Form1 (which can be seen by the class view). Just move it to another code file or after Form1 in the same file and the problem will be solved.

1

By the looks of it you might have renamed the Form1 class at some point or you have tried to copy and rename it to or from AlertDetails..

Your Form UI code is in a separate file from the main Form class, so you have to make sure that the class names match and is marked partial class Your_Form_Name in both/all files.

So lets assume your structure use to look like this:

enter image description here

Form1.cs (1) is a .cs file on its own, but it is only one part of the complete Form1 class.

In that file your class is defined like this: public partial class Form1 : Form

Form1.Designer.cs (2) is also a .cs file on its own, but it also forms part of the Form1 class.

The designer file defines the class like this: partial class Form1.

If you intended to rename Form1 to AlertDetails, you have to make sure that the class name is the same in both .cs files, Form1.Designer.cs and Form1.cs

So it should be

  • public partial class AlertDetails : Form in the Form1.cs file
  • and partial class AlertDetails in the Form1.Designer.cs file

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.