using System;
using System.Drawing;
using System.Windows.Forms;
public class PictureBoxAutoSize : Form
{
public PictureBoxAutoSize()
{
Size = new Size(550,500);
AutoScroll = true;
Image img = Image.FromFile("YourFile.bmp");
Label lblAuto = new Label();
lblAuto.Parent = this;
lblAuto.Location = new Point(0, 250);
lblAuto.Size = new Size(75,25);
lblAuto.TextAlign = ContentAlignment.MiddleRight;
lblAuto.Text = "AutoSize:";
PictureBox pbAutoBig = new PictureBox();
pbAutoBig.Parent = this;
pbAutoBig.Size = new Size(200, 200);
pbAutoBig.Location = new Point(75, 250);
pbAutoBig.BorderStyle = BorderStyle.FixedSingle;
pbAutoBig.SizeMode = PictureBoxSizeMode.AutoSize;
pbAutoBig.Image = img;
}
static void Main()
{
Application.Run(new PictureBoxAutoSize());
}
}
|