Click here to Skip to main content
13,048,406 members (105,416 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a winform on which I have tab control and I'm adding a picture box control to the tab page. I want to load an image to this picturebox control in the tab page. I'm adding the control to tab page is as follows:

m_Canvas = new PhotoCanvas();
// initializing the picture box control
m_Canvas.BackColor = Color.White;
m_Canvas.Width = 500;
m_Canvas.Height = 400;
m_Canvas.Left = 0;
m_Canvas.Top = 0;
//adding the picture box control to tabpage

I have tried to load the image using

if (m_OpenFileDialog.ShowDialog() == DialogResult.OK)
     m_Canvas.Image = new Bitmap(m_OpenFileDialog.FileName);

but it's not working means the image is not loading please help.Thanks in advance
Posted 27-Mar-13 2:23am
Updated 27-Mar-13 2:32am
ThePhantomUpvoter 27-Mar-13 8:28am
"it's not working" is not at all a helpful description of any kind of a problem. Do you call up your mechanic and and tell him "car broke" and expect he knows exactly what is wrong with your car?
Sreeju padmanabhan 27-Mar-13 8:31am
sorry :) it's not showing the image or the image is not loading to the picture box
Sreeju padmanabhan 27-Mar-13 9:16am
How can i access the pictureBox inside a tabpage of any tab control??
Sergey Alexandrovich Kryukov 27-Mar-13 10:05am
What is PhotoCanvas? The question was about a picture box, and this is a different type. Did you test it? Does it work at all?
First of all, show the code which compiles.

m_Canvas = new PhotoCanvas(); // will not compile
Sreeju padmanabhan 27-Mar-13 11:14am
Photo canvas is a class which is inherited from PictureBox.Here i'm using PhotoCanvas as same as a paint page on which i'm able to draw shapes like rectangle,ellipse ... .Now my task is to load an image in to the picturebox control (photocanvas).Hope you can help me
YAIR-I 27-Mar-13 14:39pm
I don't know what you have in the canvas class but your code work great with PictureBox. i copy your code and only changed canvas on the first line to PictureBox and it works. if you need more help you will need to add the canvas class.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100