there are a great many threads on Daniweb about passing data between forms, you should really try to find them and read them as there is a lot of helpful info there.
In order to set the contents of the viewers picturebox, you could either add an overloaded constructor method to the viewer that accepts the image as a parameter, or add a property to the viewer that allows you to set the picturebox contents.
The following sets a labels text property, but you get the idea:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnConstructor_Click(object sender, EventArgs e)
{
SubForm sub = new SubForm("Label Set by Constructor");
}
private void btnProperty_Click(object sender, EventArgs e)
{
SubForm sub = new SubForm();
sub.LabelText = "Label Set by Property";
}
}
public partial class SubForm : Form
{
public SubForm()
{
InitializeComponent();
}
public SubForm(string text)
{
InitializeComponent();
label1.Text = text;
}
public string LabelText
{
get { return label1.Text; }
set { label1.Text = value; }
}
}
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 247
Skill Endorsements: 10