0

button1_Clickで、画像のサイズを10大きくするか、ズームインしようとしています。しかし、何が起こっているのかというと、画像ボックスのサイズが大きくなり、画像に何も起こらないということです。画像のズームを続行するにはどうすればよいですか。最も簡単な方法を教えてください。

public partial class Form1 : Form
{
public Form1()
{
    InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
    // Construct an image object from a file in the local directory.
    // ... This file must exist in the solution.
    Image image = Image.FromFile("Picture1.png");
    // Set the PictureBox image property to this image.
    // ... Then, adjust its height and width properties.
    pictureBox1.Image = image;
    pictureBox1.Height = image.Height;
    pictureBox1.Width = image.Width;
  }
}
    private void Form1_Load(object sender, EventArgs e)
    {

    }
    private void button1_Click(object sender, EventArgs e)
    {
        pictureBox1.Width += 10;
        pictureBox1.Height +=10;

    }
4

1 に答える 1

0

達成しようとしていることを処理する簡単な方法は、PictureBoxのSizeModeプロパティを使用することです。StretchImageに設定します。

PictureBox.SizeModeプロパティ-MSDN

ただし、GDI +(およびおそらく安全でないコンテキスト)に慣れたら、柔軟性を高めるために、これをプログラムで実行することを検討する必要があります。

于 2012-11-11T23:52:46.077 に答える