フォームにアニメーション イメージを表示するには、次の手順を実行します。
1.)Drop a PictureBox on your Form.
2.)In the Properties Window of designer,change the image property so it contains the path to your image.
3.)Resize it as per your needs.
以上で、プロジェクトを実行してみます。例外がスローされなければ、PictureBox で画像がアニメーション表示されます。
画像を変更したい場合は、プロジェクトの実行中にいつでも、次のステートメントを使用してください。
pictureBox1.Load("Path to a new image");//Assuming you haven't renamed the PictureBox.
さらに、手作業でやりたい場合は、読んでください。
private void DisplayImage()
{
PictureBox pictureBox1=new PictureBox();
pictureBox1.Location=new Point(Use appropriate values to place the control);
this.Controls.Add(pictureBox1);
pictureBox1.Load("Path to a image to display");
}
PictureBox を表示したくない場合は、この方法で、他のユーザーが言ったように、visible プロパティを false に設定します。
pictureBox1.Visible=false;
それを元に戻すには、以下のコードを使用します。
pictureBox1.Visible=true;
アップデート :
画像を 5 秒間だけ表示するには、次のようにします。
Drop a Timer on your Form.
Set its Interval property to 5000 Milliseconds.
Create a new Event for its Tick Event (locate Tick event in Events Window and double click it).
Next modify DisplayImage() so it looks like :
private void DisplayImage()
{
timer1.Start();
PictureBox pictureBox1=new PictureBox();
pictureBox1.Location=new Point(Use appropriate values to place the control);
this.Controls.Add(pictureBox1);
pictureBox1.Load("Path to a image to display");
}
Next define an integer field(outside all functions) named count,like this;
private int count=0;
Now modify timer1_Tick() event so it looks like below;
private void timer1_Tick(object sender, EventArgs e)
{
count++;
if (count == 5)
{
SourcePictureBox.Image = null;
count = 0;
}
}
それは仕事をするべきです。他に何かあれば、私に知らせてください。