第 11 步:運行圖片檢視器應用並嘗試其他功能Step 11: Run your picture viewer app and try other features

圖片檢視器應用已完成,可以運行。Your picture viewer app is finished and ready to run. 您可以運行應用並設置 的背景PictureBox顏色。You can run your app and set the background color of the PictureBox. 要瞭解更多資訊,請嘗試通過更改表單的顏色、自訂按鈕和核取方塊以及更改表單的屬性來改進應用程式。To learn more, try to improve the application by changing the color of the form, customizing the buttons and check box, and changing the properties of the form.

如何運行應用並設置背景顏色How to run your app and set the background color

  1. 選擇 F5,或在功能表列上依序選擇 [偵錯]**** > [開始偵錯]****。Choose F5, or on the menu bar, choose Debug > Start Debugging.

  2. 在開啟圖片之前,請先選擇 [設定背景色彩]**** 按鈕。Before you open a picture, choose the Set the background color button. [色彩]**** 對話方塊隨即開啟。The Color dialog box opens.

    [色彩] 對話方塊Color dialog box
    **顏色****對話方塊Color dialog box

  3. 選擇色彩以設定 PictureBox 背景色彩。Choose a color to set the PictureBox background color. 仔細查看backgroundButton_Click()(或,)BackgroundButton_Click()方法以瞭解它的工作原理。Look closely at the backgroundButton_Click() (or, BackgroundButton_Click()) method to understand how it works.

    注意

    您可以將圖片的 URL 貼至 [開啟檔案]**** 對話方塊中,即可從網際網路載入圖片。You can load a picture from the Internet by pasting its URL into the Open File dialog box. 試著尋找透明背景的影像,以呈現您的背景色彩。Try to find an image with a transparent background, so your background color shows.

  4. 選擇 [清除圖片]**** 按鈕,確定將圖片清除。Choose the Clear the picture button to make sure it clears. 然後,通過選擇"關閉"按鈕退出應用。Then, exit the app by choosing the Close button.

嘗試其他功能Try other features

  • 使用 BackColor 屬性變更表單和按鈕的色彩。Change the color of the form and the buttons by using the BackColor property.

  • 使用 FontForeColor 屬性自訂按鈕和核取方塊。Customize your buttons and check box using the Font and ForeColor properties.

  • 變更表單的 FormBorderStyleControlBox 屬性。Change your form's FormBorderStyle and ControlBox properties.

  • 使用表單的 AcceptButtonCancelButton 屬性,如此就會在使用者選擇 EnterEsc 鍵時,自動選擇這些按鈕。Use your form's AcceptButton and CancelButton properties so that buttons are automatically chosen when the user chooses the Enter or Esc key. 當使用者選擇 "輸入" 並關閉該框時,當使用者選擇Esc時,使應用打開 "打開檔" 對話方塊。Make the app open the Open File dialog box when the user chooses Enter and close the box when the user chooses Esc.

後續步驟Next steps

若要深入了解,請繼續下列教學課程:To learn more, continue with the following tutorial:

若要回到上一個教學課程步驟,請參閱步驟 10:撰寫其他按鈕和核取方塊的程式碼To return to the previous tutorial step, see Step 10: Write code for additional buttons and a check box.

另請參閱See also