Create a pictureBox from code...Not displaying

cboshdave

Member
Joined
Dec 11, 2014
Messages
24
Programming Experience
1-3
Trying to improve my coding skills by creating a picturebox with code. I can't get it to display on my form though. Seems pretty straightforward. Probably just missing a property?? I know my image has to be resized to fit, but that should be handled by the stretchImage property? Do i have to explicitly set the docking?

C#:
{                
    PictureBox pictureBoxFirstName = new PictureBox();
    pictureBoxFirstName.Image = Properties.Resources.green_check_mark;
    pictureBoxFirstName.SizeMode = PictureBoxSizeMode.StretchImage;
    pictureBoxFirstName.Size = new Size(32, 32);
    pictureBoxFirstName.Location = new Point(130, 327);
    pictureBoxFirstName.Visible = true;
}
 
You have to add it to the Controls collection of the form. (Controls.Add)
 
Back
Top Bottom