Display Image on 2nd form
Hi, I have 2 forms, on one form i want to browse image and want to save them in array or arraylist and show on 2nd form that selected image. How would that be done?
One more query is that if i want to show that image in 2nd form can i set the size of image to be shown in a proper place as thier will be some more images will be later on adding to that form as well.
Please help. Thanks
Jan MontanoPosted May 31, 2007, 5:48 AM
Something like this...
public partial class Form2 : Form
{
private string image;
public Size ImageSize
{
get { return pictureBox1.Size; }
set { pictureBox1.Size = value; }
}
public Form2()
{
}
public Form2(string image)
{
InitializeComponent();
this.image = image;
}
private void Form2_Load(object sender, EventArgs e)
{
pictureBox1.ImageLocation = image;
}
}
Sample code
public partial class Form1 : Form
{
Form2 myForm = new Form2();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
myForm = new Form2(textBox1.Text);
myForm.Show();
}
private void button2_Click(object sender, EventArgs e)
{
myForm.ImageSize = new Size(50, 50);
}
}