Graphics Drawing in Form Load

G

Guest

I have the following in form load. When the form shows up, the graphics
vanishes.
This works, if I execute this from button_click. But, even that vanishes if
minimize and restore the form. Similar to the functionality of ClipControls =
False in VB6. How do I get to draw in a groupbox (same problem in picture
box) and retain the graphics?

Thanks in advance.
Alwin S.

SolidBrush myBrush = new SolidBrush(Color.Red);
Pen myPen = new Pen(myBrush);
Graphics g=grpDisplay.CreateGraphics();
g.DrawLine(myPen,0,15,grpDisplay.Width,15);
 
P

Paul E Collins

Al Sav said:
I have the following in form load. When the
form shows up, the graphics vanishes.

Always do your painting in the Form.Paint event or it won't be
persistent.

P.
 
F

Frank Hileman

Use a retained mode system, either following Bob's instructions, or a free
runtime like VG.net.

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 
G

Guest

Thanks for the info.

I am new to .net, but been programming for a dozen years mostly on VB. With
that credential I would like to make this comment about this graphic change
in .Net.

The way graphic drawing was implemented in VB6 seems better than this. Now,
I am tied to one event (that too, I guess, is not always fully controllable
by programmer) to make it persistent. That seems a step backwards.

A pic box is a pic box, if I want draw a line on it, I will do it from
whichever event I want to. Language implementation should not restrict me in
doing that. Now, if Windows has an inherent design anamoly that this way
(.net way) seems better for MS guys, then the windows design is not good
enough to make my life easier. This atleast is one are where .net has gone a
step behind.

Also:
An USB cable is designed to not to fit into PS/2 socket, because then USB
device wont work. Thats good design. If drawing a line on a group box from a
button click wont work, why let us do it in the first place??? Thats bad
design.

Sorry for making this stupid statement:
I there is another product by Sun, which is basically the ditto of .Net and
C#, byte for byte, except that,they let me draw line on group box and persist
it too, then I will say goodbye to MS.NET.

Alwin S.
 
P

Paul E Collins

Al Sav said:
The way graphic drawing was implemented in
VB6 seems better than this. Now, I am tied to
one event [...] to make it persistent. That seems
a step backwards.

You'll find similar mechanisms in Java, OpenGL, DirectX, etc.

If you want to draw on an image in memory at other times, you can do
so, but you must render the output to the display in the Paint event.

P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top