PC Review


Reply
Thread Tools Rate Thread

about drawing

 
 
Tony Johansson
Guest
Posts: n/a
 
      8th Apr 2011
Is it just a matter of taste which one of methods 1 and 2 I use when I want
to draw something.
I mean doeas any of them give any advantage compared to the other.

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

1 private void Form1_Paint(object sender, PaintEventArgs e)
{

}

2 protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
}
}

//Tony


 
Reply With Quote
 
 
 
 
Willem van Rumpt
Guest
Posts: n/a
 
      8th Apr 2011
On 08-Apr-11 18:53, Tony Johansson wrote:
> Is it just a matter of taste which one of methods 1 and 2 I use when I want
> to draw something.
> I mean doeas any of them give any advantage compared to the other.
>
> public partial class Form1 : Form
> {
> public Form1()
> {
> InitializeComponent();
> }
>
> 1 private void Form1_Paint(object sender, PaintEventArgs e)
> {
>
> }
>
> 2 protected override void OnPaint(PaintEventArgs e)
> {
> base.OnPaint(e);
> }
> }
>


First, it would be nice if you post complete code. I *think* I can
assume that Form1_Paint is an event handler, added somewhere in
InitializeComponent(), but without code to prove it, it could be just a
method.

Now for the answer: The end result may very well be the same, depending
on how you implement things, but the road towards it is *very* different.

In (1) you're handling an event, in (2) you're overriding a method of
the base class.

Which one is to be preferred is depends completely on whatever else
you're trying to achieve.

--
Willem van Rumpt
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing Custom Shape Using PowerPoint Drawing Tool Mosfiqur Rahman Microsoft Powerpoint 0 6th Jul 2008 01:06 PM
exporting drawing created in PowerPoint in Word as a drawing amit Microsoft Powerpoint 4 16th Mar 2008 04:19 AM
System.Drawing For Drawing Text Images jjbutera@hotmail.com Microsoft ASP .NET 1 9th Jan 2006 09:55 PM
Drawing tool bar and drawing canvas tools are dimmed with new pag. =?Utf-8?B?Sm9obk1j?= Microsoft Frontpage 3 19th Jan 2005 04:11 PM
Drawing tool bar and drawing canvas tools are dimmed with new pag. =?Utf-8?B?am1jY2FkYW1z?= Microsoft Frontpage 2 19th Jan 2005 02:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 AM.