Step 11: Run Your Program and Try Other Features


For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Your program is finished and ready to run. You can run your program and set the background color of the PictureBox. To learn more, try to improve the program by changing the color of the form, customizing the buttons and check box, and changing the properties of the form.

To download a completed version of the sample, see Complete Picture Viewer tutorial sample.

link to videoFor a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 5 or Tutorial 1: Create a Picture Viewer in C# - Video 5. These videos use an earlier version of Visual Studio, so there are slight differences in some menu commands and other user interface elements. However, the concepts and procedures work similarly in the current version of Visual Studio.

To run your program and set the background color

  1. 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. Choose a color to set the PictureBox background color. Look closely at the backgroundButton_Click() method to understand how it works.

    System_CAPS_ICON_note.jpg Note

    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 program by choosing the Close button.

To try other features

  • Change the color of the form and the buttons by using the BackColor property.

  • Customize your buttons and check box using the Font and ForeColor properties.

  • Change your form's FormBorderStyle and ControlBox properties.

  • Use your form's AcceptButton and CancelButton properties so that buttons are automatically chosen when the user chooses the ENTER or ESC key. Make the program open the Open File dialog box when the user chooses ENTER and close the box when the user chooses ESC.

To continue or review