Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
INSERT PICTURE ON WINDOWS FORM APP WHILE IT IS EXECUTING
Posted
Comments
Sergey Alexandrovich Kryukov 11-Jan-15 15:57pm    
Next time, also specify the language you use.
—SA

To insert a picture you can use a PictureBox. Not sure what you mean about "it is executing", if you have intensive work to do while the form is open you can use Background Worker so the work is done in the background and does not block/freeze the form. Otherwise you need to use InvokeRequired because accessing the form control from another thread will cause an exception.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Jan-15 15:59pm    
This is totally unrelated to threads and invocation. The question seems to be very simple. And you did not explain anything properly Please see my answer, where I also credited yours, because using PictureBox is a reasonable idea.
—SA
In addition to the answer by BacchusBeale:

Using the control System.Windows.Forms.PictureBox is just one of the way to add an image. I only would like to emphasize: each and every image or control is always added "while it is executing". Even if you do it using the designer, it is actually added "while it is executing".

Here is my general advice: if you know how to add anything using the designer but not sure how to write appropriate code by yourself, first do it under the debugger and then look at the auto-generated code. In case of Forms, it is added to your project, in case of WPF, it is not, so you would have to find it under your project's directory.

In you case, for example
C#
Control parent = // it could be any container control: Panel, TabPage, Form
PictureBox picture = new PictureBox();
picture.Image = // whatever image you want to show
// set position, dock and other required properties...
// add it:
parent.Controls.Add(picture);
// alternative way of doing the same:
//picture.Parent = parent;

Generally, this is the way to add any control.

—SA
 
Share this answer
 
Comments
Sphinz 12-Jan-15 8:23am    
Thank you Sergey,

What I mean by this is when the app appears, I need the user/customer to upload their logo into the app so that they can have a customized version of the app that shows their logo. Thanks for your help, any good code will help, I will try what you sent me as well.

Sphinz
Sergey Alexandrovich Kryukov 12-Jan-15 14:17pm    
"Any good code" is already written for you, above. This is all you need, nothing else. If you don't understand it, please ask some follow-up or separate questions.
—SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900