Questions tagged [picturebox]

The PictureBox is a control in the Windows Forms system that provides a way to display an image. It can handle many different image formats.

Summary

The PictureBox control provides a way to display images in a window constructed using the Windows Forms GUI framework. Like all other built-in controls, it inherits from System.Windows.Forms.Control and resides in the System.Windows.Forms namespace.

Important properties

In addition to all of the regular Control properties it inherits, the PictureBox also has a couple additional properties for its intended use.

Image

This property allows you to get or set an Image to be displayed in the PictureBox. Any image format supported by GDI+ can be used for this property. See the "Types of Bitmaps" article on MSDN for a list of supported formats.

SizeMode

This property determines how to display the Image within the PictureBox. It accepts a PictureBoxSizeMode value, which says whether the image should be centered, stretched, etc. (To change the size of the PictureBox control itself, use the ClientSize property.)

Links

2606 questions
81
votes
11 answers

Fit Image into PictureBox

using (SqlConnection myDatabaseConnection = new SqlConnection(myConnectionString.ConnectionString)) { myDatabaseConnection.Open(); using (SqlCommand SqlCommand = new SqlCommand("Select Photo from Employee where EmpID LIKE '%' + @EmpID + '%'…
Karlx Swanovski
  • 2,869
  • 9
  • 34
  • 67
77
votes
5 answers

How can I get scrollbars on Picturebox

I have PictureBox picture. I use: picture.Size = bmp.Size; picture.Image = bmp; Let's say there are two integers maxWidth and maxHeigth. I want to add vertical/horizontal scrollbar to picture when its size exceeds maxWidth and/or maxHeight. How can…
Ichibann
  • 4,371
  • 9
  • 32
  • 39
50
votes
14 answers

Clear image on picturebox

How can I clear draw image on picturebox? The following doesn't help me: pictbox.Image = null; pictbox.Invalidate(); Please help. EDIT private void pictbox_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; vl.Draw(g,…
ktarik
  • 653
  • 1
  • 6
  • 9
48
votes
9 answers

Free file locked by new Bitmap(filePath)

I have the Image of a PictureBox pointing to a certain file "A". At execution time I want to change the Image of the PictureBox to a different one "B" but I get the following error: "A first chance exception of type 'System.IO.IOException'…
MrCatacroquer
  • 2,038
  • 3
  • 16
  • 21
46
votes
5 answers

Load an image from a url into a PictureBox

I want to load an image into a PictureBox. This is the image I want to load: http://www.gravatar.com/avatar/6810d91caff032b202c50701dd3af745?d=identicon&r=PG How do I do this?
Vishnu Pradeep
  • 2,087
  • 2
  • 29
  • 56
41
votes
7 answers

How to make picturebox transparent?

I am making an application in C# .NET. I have 8 picture boxes in it. I used PNG images with transparent background but in my form it is not transparent when it comes above another image. I am using Visual Studio 2012. This is a screenshot of my…
Belal Khan
  • 2,099
  • 2
  • 22
  • 32
39
votes
2 answers

Print images c#.net

I have an image in a PictureBox, and I want to print it. No formatting, no nothing, just print it. I've been searching on Google but I've got nothing, only people printing forms or text or reports. private string imgSrc; public string ImgSrc …
34
votes
6 answers

Change PictureBox's image to image from my resources?

How do I set a PictureBox image to an image from my resources? (I tried this without success: pictuerbox.Image = "img_location";)
MasterMastic
  • 20,711
  • 12
  • 68
  • 90
33
votes
6 answers

Load image from resources

I want to load the image like this: void info(string channel) { //Something like that channelPic.Image = Properties.Resources.+channel } Because I don't want to do void info(string channel) { switch(channel) { case "chan1": …
a1204773
  • 6,923
  • 20
  • 64
  • 94
31
votes
4 answers

How do I make a PictureBox use Nearest Neighbor resampling?

I am using StretchImage because the box is resizable with splitters. It looks like the default is some kind of smooth bilinear filtering, causing my image to be blurry and have moire patterns.
Jared Updike
  • 7,165
  • 8
  • 46
  • 72
28
votes
4 answers

PictureBox Tooltip changing C#

Ok so I am a complete beginner and have managed to put together a small app in C# where I enter a username in a textbox and the application gets the avatar of that username and displays it in a picturebox. What i want to do is have a tooltip show…
BrandNewDev
  • 755
  • 2
  • 9
  • 16
28
votes
5 answers

Loading PictureBox Image from resource file with path (Part 3)

I understand that this question has been asked (and answered) before. However, none of the solutions are working for me. Below is a screen capture of all the relevant pieces of the puzzle: Screen capture…
zetar
  • 1,225
  • 2
  • 20
  • 45
26
votes
6 answers

Transparent images with C# WinForms

I am working on a Windows Forms application in VS 2008, and I want to display one image over the top of another, with the top image being a gif or something with transparent parts. Basically I have a big image and I want to put a little image on top…
Fiona
  • 7,747
  • 4
  • 19
  • 8
24
votes
3 answers

Right way to dispose Image/Bitmap and PictureBox

I am trying to develop a Windows Mobile 6 (in WF/C#) application. There is only one form and on the form there is only a PictureBox object. On it I draw all desired controls or whatever I want. There are two things I am doing. Drawing custom shapes…
Kornelije Petak
  • 9,412
  • 15
  • 68
  • 96
23
votes
6 answers

C# Picturebox transparent background doesn't seem to work

For a project of mine I need images to display with a transparent background. I made some .png images that have a transparent background(to check this I opened them in Photoshop). Now I have a class that extends PictureBox: class Foo : PictureBox { …
teuneboon
  • 4,034
  • 5
  • 23
  • 28
1
2 3
99 100