Windows Form 設計工具概觀Windows Forms Designer overview

Visual Studio 中的 Windows Form 設計工具能針對建立以 Windows Forms 為基礎的應用程式提供快速的開發解決方案。Windows Forms Designer in Visual Studio provides a rapid development solution for creating Windows Forms-based applications. Windows Form 設計工具可以讓您輕鬆地將控制項加入表單,排列它們,然後撰寫其事件的程式碼。Windows Forms Designer lets you easily add controls to a form, arrange them, and write code for their events. 如需 Windows Forms 的詳細資訊,請參閱 Windows Forms 概觀For more information about Windows Forms, see Windows Forms overview.

功能Functionality

透過使用設計工具,您可以:Using the designer you can:

  • 將元件、資料控制項,或是以 Windows 為基礎的控制項新增到表單上。Add components, data controls, or Windows-based controls to a form.

  • 在設計工具中按兩下表單並撰寫該表單之 Load 事件的程式碼,或是按兩下表單上的控制項並撰寫該控制項預設事件的程式碼。Double-click the form in the designer and write code in the Load event for that form, or double-click a control on the form and write code for the control's default event.

  • 選取控制項來編輯該控制項的 Text 屬性並輸入名稱。Edit a control's Text property by selecting the control and typing a name.

  • 使用滑鼠或方向鍵來移動控制項,來調整所選取之控制項的位置。Adjust the placement of the selected control by moving it with the mouse or the arrow keys. 同樣地,使用 Ctrl 和方向鍵來更精確地調整位置。Similarly, adjust the placement more precisely using the Ctrl and arrow keys. 最後,使用 Shift 和方向鍵來調整控制項的大小。Finally, adjust the size of the control by using the Shift and arrow keys.

  • 在按一下時選取 ShiftCtrl 來選取多個控制項。Select multiple controls by selecting either Shift or Ctrl while you click. 使用 Shift+按一下時,所選取的第一個控制項將會是對齊或調整大小時的主要控制項。When using sing Shift+click, the first control selected is the dominant control when aligning or manipulating size. 使用 Ctrl+按一下時,最後選取的控制項將會是主要控制項,因此主要控制項會隨著新增控制項而變更。When using Ctrl+click, the last control selected is dominant, so the dominant control changes with every new control added. 或者,您也可以拖曳選取矩形來涵蓋您想要選取的控制項,以選取多個控制項。Alternatively, you can select multiple controls by dragging a selection rectangle around the controls that you want to select.

注意

使用 Windows Form 設計工具 (而非資源編輯器) 來變更表單的資源 (.resx) 檔案。Use Windows Forms Designer, and not the Resource Editor, to make changes to a form's resource (.resx) file. 如果您編輯以表單為基礎的 .resx 檔案,您將會看見警告,表示您在資源編輯器中所做的變更可能會遺失。If you edit a form-based .resx file, you'll see a warning that changes you make in the Resource Editor may be lost. 這是因為該 .resx 檔案是由 Windows Form 設計工具產生。This is because the Windows Forms Designer generates the .resx file.

另請參閱See also