Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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;
this.MainTab.TabPages[0].Controls.Add(m_Canvas);
//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 3:23am
Edited 27-Mar-13 3:32am
(no name)131.4K
v5
Comments
ThePhantomUpvoter at 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 at 27-Mar-13 8:31am
   
sorry :) it's not showing the image or the image is not loading to the picture box
Sreeju padmanabhan at 27-Mar-13 9:16am
   
How can i access the pictureBox inside a tabpage of any tab control??
Sergey Alexandrovich Kryukov at 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
—SA
Sreeju padmanabhan at 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 at 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
0 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2014
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