Graphics Drawing in Form Load

  • Thread starter Thread starter Guest
  • Start date Start date
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);
 
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.
 
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
 
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.
 
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.
 
Back
Top