Results 1 to 4 of 4

Thread: [RESOLVED] User Control form disappears from Solution Explorer

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2012
    Posts
    30

    Resolved [RESOLVED] User Control form disappears from Solution Explorer

    I add a user control to my project and it shows up in the solution explorer with the icon that designates it
    as a form. As I go moving things around on the control I'll accidentally double-click it and the code page
    pops up as it usually does.

    However now when I go to the solution explorer the file now has the icon that designates it as a code file.
    The file with the icon designating it as a form is gone and there is no way to open the user control in the
    designer.

    Where did the file go that you could right-click on and open it in the designer?

    Thanks

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,440

    Re: User Control form disappears from Solution Explorer

    Are you saying that this happens every time you create a user control or did it happen just once and you can't replicate it? If it's the former then you probably need to repair VS. If it's the latter then I wouldn't worry too much as these things happen from time to time. VS has bugs, just like any software, but things that happen inconsistently like this are very hard to diagnose.

    You may well be able to repair this particular user control with a bit of jiggery pokery. I've done the following sort of thing with a few forms and it has worked so hopefully you'll get similar results. Start by adding a new WinForms project and then, in the Solution Explorer, drag your user control item from the existing project to the new project. Hopefully, it will appear normally. Play with the new project until you can get it run and display an instance of the UC and then delete the item from the original project and drag it back from the new project. Again, hopefully it will appear normally. Get the original project to run and display an instance of your UC again and then delete the new project.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2012
    Posts
    30

    Re: User Control form disappears from Solution Explorer

    Okay, found it.

    I'm designing the user interface first figuring on adding all the code afterwards. When I double-clicked on the user control the code page came up with the following code -

    Code:
    Public Class My_User_Control
    
        Private Sub My_User_Control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    
    End Class

    Thinking "Well, I don't need any code right now, I'm going to do all of that later" I would delete all of the code including the class definition.

    Whoopsie!

    It seems deleting the class definition from the associated code will remove the form from the Solution Explorer. The code page is still there but it's just a blank file. I re-inserted the class definition and the form reappeared in the Solution Explorer.

    Oh well , that's how you learn !

    Thanks to jmcilhinney for the reply !

  4. #4
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,612

    Re: [RESOLVED] User Control form disappears from Solution Explorer

    What probably caused the problem was removing the load event. It's not obvious when you first start working with forms but when open a something in the designer it runs the same code to show it in visual studio as it does when showing that element at run time - including (among other things) the load event. This can cause some real confusion if you happen to have put code in there that depends on things that will only exist at run time, it prevents the designer from loading it.
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width