2010-03-18 49 views

回答

2

您可以打開設計器代碼文件並直接複製需要的位。

您需要複製聲明(底部),實例化和任何BeginInit調用(InitializeComponent的頂部),屬性(標註有註釋),最後在底部複製EndInit調用。您還必須確保將所有控件添加到窗體/用戶控件的控件集合中,也位於底部。

private void InitializeComponent() 
{ 
    this.components = new System.ComponentModel.Container(); 
    this.button = new System.Windows.Forms.Button(); 
    this.SuspendLayout(); 
    // 
    // button 
    // 
    this.button.Location = new System.Drawing.Point(1, 5); 
    this.button.Name = "Button1";   
    this.button.Size = new System.Drawing.Size(20, 50); 
    // 
    // Form1 
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
    this.Controls.Add(this.button); // This is important 
    this.Name = "Form1"; 
    this.Size = new System.Drawing.Size(569, 394); 
    this.ResumeLayout(false); 
} 

#endregion 

private System.Windows.Forms.Button button; 
+0

這是一個好主意。我開始思考這些問題 - 尤其是考慮到我將從這裏找到並替換。感謝您有關如何做到這一點的細節。 –

+0

我剛剛完成。這是一個嚴重的任務LOL。但是它比單獨重命名300多個控件要好,因爲它只是每個控件的一部分,需要重命名。 –

+0

@Ready Cent,考慮接受這個答案。只是提醒。 –

4

我使用VS 2010 RC 1,和我的機器在VS 2008是「向下」,所以我不知道這個特殊的功能(就地控制名稱的編輯)是在VS2008中:但在情況下,它是:直接控制的名字中選擇文檔大綱視圖

  • 編輯:

    1. 打開菜單查看/其他窗口。

    它看起來像「文檔大綱」視圖已經存在了很長一段時間:以前的版本Document Outline View,但是否支持就地控制名稱的編輯:我不知道。

  • +0

    這是我在一段時間看到的VS2010最有用的功能之一。謝謝! – SomethingBetter

    1

    在VS2010中,進入工具 - >選項。在選項列表中找到文本編輯器 - > HTML->雜項。 取消選中源視圖中粘貼自動ID元素旁邊的複選框。

    +0

    不完全適用於Windows窗體,但我也在尋找ASPX解決方案。 –