ComponentOne Input for WinForms
In This Topic
    Customizing the PictureBox
    In This Topic

    Like most controls, you can easily increase or decrease the size of the C1.Input.PictureBox either using your mouse or through the C1.Input.PictureBox.Size property. But, depending on the dimensions of the picture files, an image might be cut off or might leave a large blank space showing within the PictureBox:


    Or…


    Perhaps you want your image to appear larger when the program runs. If you increase the size of the PictureBox control you still need to alter the Input.PictureBox.SizeMode for the picture to stretch to the controls boundaries.

    To Expand the Image in the PictureBox

    1. Create .NET project and add the following controls to your form.
      • C1ExpressTable1 (C1.Data.Express.C1ExpressTable)
      • C1Label1-3 (C1.Win.C1Input.C1Label)
      • C1PictureBox1 (C1.Win.C1Input.C1PictureBox)
      • C1TextBox1 (C1.Win.C1Input.C1TextBox)
      • C1DbNavigator1 (C1.Win.C1Input.C1DbNavigator)
    2. Arrange the controls to resemble the form below:
    3. Enter the following to the C1.Data.Express.C1ExpressTable.ConnectionString property:

      "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="Documents\ComponentOne Samples\Common\C1NWind.mdb"

      Note: Step 3 assumes that you have the sample file, C1NWind.mdb, in the default location created upon installing the ComponentOne controls. If your database file is in a different location or you want to use a different database file, adjust this entry appropriately.

    4. Using the Properties window, bind the remaining controls to the database:
      Visual Style Description
      C1DbNavigator1.DataSource C1ExpressTable1
      C1Label1.DataSource C1ExpressTable1
      C1Label1.DataField LastName
      C1Label2.DataSource C1ExpressTable1
      C1Label2.DataField FirstName
      C1Label3.DataSource C1ExpressTable1
      C1Label3.DataField HireDate
      C1PictureBox1.DataSource C1ExpressTable1
      C1PictureBox1.DataField Photo
      C1TextBox1.DataSource C1ExpressTable1
      C1TextBox1.DataField Notes

      If you ran the program now, the images shown when cycling through the database would not fill the picture box and a large blank space would appear on the form. You need to stretch the image to the boundaries of the PictureBox.

    5. Change the C1PictureBox1.SizeMode property from Normal to StretchImage. Notice that there are 3 other options to choose from as well.
    6. Run the program and notice how large the employee photo appears.
    See Also