By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,906 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,906 IT Pros & Developers. It's quick & easy.

Graphics Drawing in Form Load

P: n/a
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);

Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Al Sav" <Al***@discussions.microsoft.com> wrote:
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.
Nov 16 '05 #2

P: n/a
See the GDI+ FAQ #1 annoying question for all the details.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Al Sav" <Al***@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
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);

Nov 16 '05 #3

P: n/a
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

"Al Sav" <Al***@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
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);

Nov 16 '05 #4

P: n/a
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.

"Bob Powell [MVP]" wrote:
See the GDI+ FAQ #1 annoying question for all the details.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Al Sav" <Al***@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
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);


Nov 16 '05 #5

P: n/a
"Al Sav" <Al***@discussions.microsoft.com> wrote:
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.
Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.