2

I have a VB app which draws primitive shapes (lines, filled rectangles etc.) into a picturebox control (from its paint event). I've since found out that a picturebox is probably the worst control to use for this. I've also found out that it's better to draw directly onto the form but I don't really want to do this as a control gives clipping for 'free'.

What would be the best control for this? The panel control looks like a good candidate but the experiment I tried actually performed worse!

Thanks.

ajordison
  • 55
  • 6
  • "I've since found out that a picturebox is probably the worst control to use for this" - where did you 'find this out', and what did that source recommend you use instead? – AakashM Aug 16 '11 at 09:36
  • From [here](http://www.bobpowell.net/picturebox.htm). Though I seem to remember other sites saying the same thing. – ajordison Aug 16 '11 at 09:59
  • I'm certainly not going to disagree with Bob Powell :) So you're saying that "If you want a handy placeholder for a graphic that works within a set bounds, use a Panel control and service its Paint event" gave poor peformance? – AakashM Aug 16 '11 at 10:21
  • Well, the poor performance was probably due to other factors, not a fault with the panel control. Anyway, I think I'll persevere with the panel control as it's most likely something else I'm doing wrong! – ajordison Aug 16 '11 at 10:32
  • @ajordison The panel is what you most likely want. Show some code and we can fix the drawing issue. – LarsTech Aug 16 '11 at 11:36
  • I had another go at it and used a label control in the end. The performance was much better than using the picturebox. I think the problem was I was manually refreshing the panel control when it didn't need it, so there was a lot of flickering. Are there any objections to using a label control to draw in? It seems an odd choice but it works very well. – ajordison Aug 16 '11 at 12:15
  • @ajordison How are you drawing shapes in the Label control? And why would that work better than a Panel? Try editing your question and adding some code. – LarsTech Aug 16 '11 at 15:22
  • @LarsTech - I just used the e.graphics from the label control's paint event to draw the shapes. I meant that the label performed better than the way I used the panel control so unless there are alarm bells going because I'm using a label instead of a panel I'll leave it as is. – ajordison Aug 17 '11 at 12:57

1 Answers1

1

Talking of primitive shapes, if you ever want a shaped control or a shaped Form like a hexagon shaped button or /and an oval Form and things like that then take a look at my code in this MSDN thread please:>>

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/0cab1cbd-553c-4ac2-97ec-334a4338484d