记录

来源:互联网 发布:手机淘宝查看订单 编辑:程序博客网 时间:2024/04/30 22:04
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";
        }
    }
}
原创粉丝点击