|
-
August 26th, 2009, 03:07 PM
#1
How to load a picturebox from different classes?
I have a mainform.
On this main form are two controls: 1) a thumbnail panel and 2) a picturebox. I created them as separate class files so they I can use them with any programs. I just dropped both controls in a split panel on the mainform. Thumbnail on left and picturebox on right.
When the user clicks the thumbnail I want the picture box to show.
However the thumbnail click events are associated with the thumbnail. The picturebox is supposed to be loaded within the click event of the thumbnail but doesnt. I need help.
Here is my code
private void thumbnail_MouseClick(object sender, MouseEventArgs e)
{
ImageBox kimg = new ImageBox();
int iImgNum = Convert.ToInt16(((PictureBox)(Control)sender).Name);
string ImgNum = ((PictureBox)(Control)sender).Name.ToString();
string ImgFileName = @"C:\Images\Image" + ImgNum + ".tif";
kimg.GetImage(ImgFileName);
}
namespace ImageTest
{
public partial class ImageBox : UserControl
{
public ImageBox()
{
InitializeComponent();
}
public void GetImage(string file)
{
this.picturebox1.image= Image.FromFile( file
this.picturebox1.show();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|