Archived

This topic is now archived and is closed to further replies.

yaroslavd

Drawing on a Control with VB.Net 2003

Recommended Posts

I want to be able to draw on a custom control (subclass of TabPage) using the Design View. I can overload the OnPaint(...) method, which works fine. However, it would be great if I could use the Design view to really draw on the control. What I have in mind is something like a tab in the Toolbox (like "Windows Forms"), that would have things like Line or Rectangle that you just drag onto the control,like you would drag a Button onto a Form. Does something like this exist in VB.Net 2003? I was unable to find such a thing. If you can help, please respond. Thanks in advance.

Share this post


Link to post
Share on other sites
If the drawing you want to make is pre determined at design time, shouldn''t you use a specialized drawing program (photoshop, paint) to create the drawing and just set it as the background picture for your control?

Share this post


Link to post
Share on other sites
Yeah, I guess I didn''t exactly know what I wanted. What I''m really looking to do, now that I think about it, is to programmatically draw things on the control and be able to look at it thru the design view.

For example, let''s say I have a control called ABC. The constructor accepts two values: x and y coordinates of the point to be drawn on the control. I want to be able to input sample values and have the control display the point with those values without running the code.

I realize this is stupid and most likely can''t be done. Please excuse my utter stupidity. However, if by some chance this IS possible, please tell me.

Share this post


Link to post
Share on other sites
Warning - I'm talking out of my arse here, but bear with me.
If I recall correctly, when you add a control to the designer, it's constructor is executed (I think this is how some of the controls are able to display some information at design time)
So it may be possible for you to start a timer in the contructor and on that timer tick event draw whatever you want (you may have to clear the background and get a graphics object your self rather than rely on refresh/paint() events) - it may show it in the designer (note that I have never done this and I don't know if it's possible.)

That said, even if it works it's a lot of trouble when compared to just running your program...

Anyway, good luck.

[edited by - alexmoura on January 24, 2004 12:46:46 AM]

Share this post


Link to post
Share on other sites