日期:2014-05-19  浏览次数:20759 次

VS2005开发Addin时,如何知道设计器上的控件和属性。
请知道的给个提示,我死活也没找出来     。因为不想去读   代码来识别。想直接使用   接口提供的   对象来操纵。


------解决方案--------------------
我会
------解决方案--------------------
有人
------解决方案--------------------
http://www.cnblogs.com/dudu/archive/2007/02/06/642229.html
http://www.cnblogs.com/dudu/archive/2007/02/01/635746.html
------解决方案--------------------
http://www.chenjiliang.com/Article/View.aspx?ArticleID=513&TypeID=73
------解决方案--------------------
addin是什么意思?
------解决方案--------------------
public void AddControlsDelegate(DTE2 dte)
{
Project prj = (Project)((Array)dte.ActiveSolutionProjects).GetValue(0);
ProjectItem item = prj.ProjectItems.Item( "Form1.cs ") as ProjectItem;
Window itemDesigner = item.Open(Constants.vsViewKindDesigner);
itemDesigner.Activate();
IDesignerHost host = itemDesigner.Object as IDesignerHost;

IContainer ic = host.Container;

(ic.Components[ "textBox1 "] as System.Windows.Forms.TextBox).Size = new Size(200, 21);

foreach (IComponent cp in ic.Components)
{
if (cp is System.Windows.Forms.Button)
{
(cp as System.Windows.Forms.Button).Text = "aa ";
}
}
}