PictureBox Constructor
Collapse the table of content
Expand the table of content

PictureBox Constructor ()


Initializes a new instance of the PictureBox class.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public PictureBox()

The following table shows initial property values for an instance of the PictureBox class.







The following code example demonstrates the use of the PictureBox and ListView controls. The PictureBox is initialized by setting the BorderStyle and SizeMode properties using the BorderStyle and PictureBoxSizeMode enumerations, respectively. The ListView is populated with pictures from the Sample Pictures directory. The ListView.GetItemAt method is used when handling the MouseDown event of the ListView control to determine whether an item is selected. If an item is selected, the event handler displays the selected file by setting the Image property. The example requires that you have JPG files located in the C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures directory. To run the example, paste the code into a form and call the InitializePictureBox and PopulateListView methods in the form's constructor or Load event-handling method. Ensure all events are associated with their event-handling methods.

Snippet section 2 of code snippet {"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"b913419a-5dc3-4318-ae90-fbc75176961c","entity_type":"CodeSnippet","locale":"en-US"} in source file ({"filename":"/CS/form1.cs","blob_type":"Source","blob_id":"-002fcs-002fform1-002ecs","blob_revision":3}) overlaps with other snippet sections. Ensure the tags are placed correctly.

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft