Click here to Skip to main content
15,065,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have a problem regarding appending a picture within a picturebox.
There is a a panel, that contains FORMNAME-textbox, FORM-Picturebox. Save-button.
in the menu strip, I have a combobox that displays the names of the picture-templates that have been saved in database. If you choose one of them, its corresponding image appears in the PictureBox.

all of the above is working well. What i have been trying to do is to append a generated image from a signature(that would be a picture too) if i opened the items in the combobox. I have a specific place where to put it in the FORM-picture but i cant put it there because the only show the Panel and the Picturebox(which is Auto SIzed btw) in which i put the FORM.

anyone have an idea? please help me.

I can give the project in vb so that you can see what my problem is, i cant upload it here..
Updated 22-Mar-12 8:30am

1 solution

Do yourself a favor, don't torture yourself abusing PictureBox. This is a very usual mistake.

This control is only good to do something very simple, like showing just one picture (well, maybe changing it, but not often). When you try to do anything more tricky, such as dynamic, interactive, animated, etc., it turns out to be more of an obstacle then a help, eating up your development time, computer performance and extra resources, giving nothing useful in return.

Compared to what? To a custom control derived from System.Windows.Forms.Control with graphics rendered in the handler of the event Paint, or, better yet, overridden virtual method OnPaint.

I explain how in my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^].

See also other answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^].

kimsnap 22-Mar-12 14:34pm
hi sir can i push your kindness a bit more, i would like to show you what have i done and what i am trying to do. so that you'll understand me more..
is there a way that i can upload my project here?
Sergey Alexandrovich Kryukov 22-Mar-12 15:23pm
Sure, I don't mind, but I don't want to consider using PictureBox anymore -- it would be a waste of time. It would be the best if you conceptually describe the goal (including the ultimate goal of the project) and the workflow. Using "Improve question" and appending the information would be the best, but in this case please notify me by commenting this message, if you want me to respond, OK?
kimsnap 22-Mar-12 16:07pm
the picturebox, wow. To be honest sir i dont have another idea what to use. :( i have uploaded my work
it have description there but please tell me if there is something to ask.. thank a lot.
Sergey Alexandrovich Kryukov 22-Mar-12 16:40pm
To be honest, you can easily get that idea if you simply read my answers I referenced above. This is much simpler and less wasteful then PictureBox. As I say, this design mistake is very typical. You don't need to repeat it. If something is unclear, please ask further questions.
Sergey Alexandrovich Kryukov 22-Mar-12 16:41pm
Please, let me explain: you are interested to ask me, not that I'm interested to ask you. I already pointed out where you go wrong. If you disagree, you are welcome to argue, of course.
Shahin Khorshidnia 22-Mar-12 16:28pm
Sergey Alexandrovich Kryukov 22-Mar-12 16:38pm
Thank you, Shahin.
kimsnap 22-Mar-12 17:13pm
ok thanks im sorry if i sound demanding or anything offensive to you.. ill look them up again..
Sergey Alexandrovich Kryukov 22-Mar-12 21:40pm
No, no, please don't get me wrong... nothing offensive whatsoever. Everything is all right. I'm talking about purely practical situation: I think I we should first simplify the situation by subtractive PictureBox from equation; it's just redundant level of indirection which could be useful only in simple static situation. A minimal complication like "append a picture" makes it impractical, redundant, not helping anymore. I suggest you how to get a background on how graphics is rendered on more direct level (a PictureBox implementation is just a specialized case of it oriented for static applications). When you look at it, you will more clearly see the problem. OK? This is not hard to go...

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