步驟 3:設定您的表單屬性Step 3: Set your form properties

接下來,您要使用 [屬性]**** 視窗變更表單的外觀。Next, you use the Properties window to change the way your form looks.

如何設置表單內容How to set your form properties

  1. 確定您在查看 Windows Forms 設計工具Be sure you're looking at Windows Forms Designer. 在 Visual Studio 整合式開發環境 (IDE) 中,選擇 [Form1.cs [設計]]**** 索引標籤 (或 Visual Basic 中的 [Form1.vb [設計]]**** 索引標籤)。In the Visual Studio integrated development environment (IDE), choose the Form1.cs [Design] tab (or the Form1.vb [Design] tab in Visual Basic).

  2. 選擇表單 [Form1]**** 內的任何位置來選取它。Choose anywhere inside the form Form1 to select it. 查看 [屬性]**** 視窗,現在應該會顯示表單的屬性。Look at the Properties window, which should now be showing the properties for the form. 表單有各種屬性。Forms have various properties. 例如,您可以設定前景和背景色彩、表單頂端顯示的標題文字、表單的大小和其他屬性。For example, you can set the foreground and background color, title text that appears at the top of the form, size of the form, and other properties.

    注意

    如果未顯示 "屬性" 視窗,請通過選擇工具列上的方形 "停止調試" 按鈕停止應用,或者只是關閉視窗。If the Properties window doesn't appear, stop your app by choosing the square Stop Debugging button on the toolbar, or just close the window. 如果應用已停止,但仍看不到"屬性" 視窗,則在功能表列上選擇 "查看 > 屬性"視窗If the app is stopped and you still don't see the Properties window, on the menu bar, choose View > Properties Window.

  3. 選取表單之後,在 [屬性]**** 視窗中尋找 [文字]**** 屬性。After the form is selected, find the Text property in the Properties window. 根據清單排序的方式,您可能需要向下捲動。Depending on how the list is sorted, you might need to scroll down. 選擇文本,鍵入圖片檢視器,然後選擇EnterChoose Text, type Picture Viewer, and then choose Enter. 您的表單現在應在其標題列中包含文本圖片檢視器,並且 "屬性" 視窗應類似于以下螢幕截圖。Your form should now have the text Picture Viewer in its title bar, and the Properties window should look similar to the following screenshot.

    屬性視窗Properties window
    **屬性****視窗Properties window

    注意

    屬性可以依 [分類]**** 或 [字母順序]**** 檢視來排序。Properties can be ordered by a Categorized or Alphabetical view. 您可以使用 [屬性]**** 視窗上的按鈕,在這兩個檢視之間切換。You can switch between these two views by using the buttons on the Properties window. 在本教學課程中,透過 [字母順序]**** 檢視比較容易找到屬性。In this tutorial, it's easier to find properties through the Alphabetical view.

  4. 返回 Windows Forms 設計工具Go back to Windows Forms Designer. 選擇表單的右下方拖曳控點,即表單右下方的白色小方塊,如下所示。Choose the form's lower-right drag handle, which is the small white square in the lower-right of the form and appears as follows.

    拖動手柄Drag handle
    拖動手柄Drag handle

    拖曳控點來調整表單大小,使表單變得較寬且稍微高一些。Drag the handle to resize the form so the form is wider and a bit taller.

  5. 查看 [屬性]**** 視窗,並注意 Size 屬性已變更。Look at the Properties window, and notice that the Size property has changed. 每當您調整表單的大小時,Size 屬性就會變更。The Size property changes each time you resize the form. 嘗試拖曳表單的控點,將其調整為大約 550, 350 (不需要很精確) 的表單大小,這樣應該很適合此專案。Try dragging the form's handle to resize it to a form size of approximately 550, 350 (no need to be exact), which should work well for this project. 作為替代方法,可以直接在Size屬性中輸入值,然後選擇Enter鍵。As an alternative, you can enter the values directly in the Size property and then choose the Enter key.

  6. 再次運行應用。Run your app again. 請記住,您可以使用以下任何方法運行應用。Remember, you can use any of the following methods to run your app.

    • 選擇 F5 鍵。Choose the F5 key.

    • 在功能表列上,選擇調試 > 開始調試On the menu bar, choose Debug > Start Debugging.

    • 在工具列上選擇 [開始偵錯]**** 按鈕,如下所示。On the toolbar, choose the Start Debugging button, which appears as follows.

      [開始偵錯] 工具列按鈕Start Debugging toolbar button
      **開始調試****工具列按鈕Start Debugging toolbar button

      與之前一樣,IDE 生成並運行你的應用,並顯示一個視窗。Just like before, the IDE builds and runs your app, and a window appears.

  7. 在開始下一步之前,請停止應用,因為 IDE 不會允許您在應用運行時更改應用。Before going to the next step, stop your app, because the IDE won't let you change your app while it's running. 請記住,您可以使用以下任何方法停止應用。Remember, you can use any of the following methods to stop your app.

    • 在工具列上選擇 [停止偵錯]**** 按鈕。On the toolbar, choose the Stop Debugging button.

    • 在功能表列上,選擇調試 > 停止調試On the menu bar, choose Debug > Stop Debugging.

    • 使用鍵盤,然後按Shift+F5Use your keyboard and press Shift+F5.

    • 選擇 "圖片檢視器" 視窗右上角的X按鈕。Choose the X button in the upper corner of the Picture Viewer window.

後續步驟Next steps

另請參閱See also