Adding controls to a form when I only have the reference to it’s EnvDTE

為{幸葍}努か 提交于 2020-01-06 12:50:30

问题


I am writing na Add-In for Visual Studio 2010, and I want it to add controls to an existing Form in an existing Project in an existing Solution, and I already have references to all of them.

As I have the reference to the Project Item that represents the file of the form, I want a reference to the Form per se, then I’ll be able to do anything to it (changing properties, and adding controls).

I have tried some approaches, though I must admit I haven’t ran out of tries. But since this is quite an interesting subject, instead of keeping on beating around the bush, I decided to write this question, so it would be faster for me, and would be registered for future similar doubts from anyone else.

Summarizing:

I have:

EnvDTE.ProjectItem myPrjItemForm

And I want to have:

System.Windows.Forms.Form myFormObject

回答1:


Have a look at these articles:

HOWTO: Add a control to a Windows form from a Visual Studio add-in

HOWTO: Manipulating controls of Windows forms from Visual Studio .NET add-ins

It's VB code, but as far as I can tell, it illustrates the steps you need to perform.



来源:https://stackoverflow.com/questions/5185370/adding-controls-to-a-form-when-i-only-have-the-reference-to-it-s-envdte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!