locked
How can I generate Form from "filename.designer.cs" file? RRS feed

  • Question

  • Hi everyone,

    I was building a VB C# project and building the form (UI). When I re-open the "windowsformapplication2" file it only open the code for the UI not the actual form. Can anyone help me to figureout how to open the Form (UI) for this designer.cs file.

    Thank  you


    • Edited by ShapedWorld Friday, October 7, 2016 5:40 PM
    Friday, October 7, 2016 4:59 PM

Answers

  • Designing in Windows Forms works via Partial Classes. Indeed it is the original canonical example for that code.

    You work on one File (the .cs)
    The designer works on and graphically represents the other (the .designer.cs)
    At compile time both parts are fused into a single class, as usual for the rules of partial classes.
    The Designer code is executed when the constructor calls "InitialiseComponents()".

    Ideally do not put any custom code earlier then "FormLoaded" Event.
    But at least you should let InitialiseComponents() run before your code.


    Remember to mark helpfull answers as helpfull and close threads by marking answers.

    Friday, October 7, 2016 6:41 PM