Cannot Place User Control on Form

前端 未结 8 1258
南笙
南笙 2020-12-06 03:48

I\'ve created a C# WinForms application using VS2010. I\'m new to creating user controls so I created a new user control (as part of the same project).

When I rebuil

8条回答
  •  难免孤独
    2020-12-06 04:33

    I had this problem in VS2015 and the solution turned out to be simple.

    I had created a user control by cutting and pasting a few existing controls from a form (with the aim of grouping them into the custom control). The custom control was okay (no compile errors), however the removal of the controls from the existing form meant that the application wouldn't compile. Of course not being able to add the new control meant that I couldn't update the code referencing the previous controls with code referencing the custom control.

    All I did was hack and slash (commenting-out, creating temporary controls, etc.) so that the entire application would compile. After it compiled I found that I could drag the custom control onto the form (without the error that prompted this question). I then had to unhack and unslash so that the code properly referenced the new custom control.

提交回复
热议问题