Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating graphics using C#.NET
I have following coding
I am not able to get how to call method..Just see to it

C#
public void paint(object sender,PaintEventArgs e) 
        {
            e.Graphics.PageUnit = GraphicsUnit.Inch;
            TextureBrush tb = new TextureBrush(Image.FromStream(GetType().Assembly.GetManifestResourceStream("tbinch.Bitmap1.bmp")));
            Matrix mx = new Matrix(1f / e.Graphics.DpiX, 0, 0, 1f / e.Graphics.DpiY, 0, 0);
            tb.Transform = mx;
            e.Graphics.FillRectangle(tb, 0, 0, 5, 5);
        }


I have taken one button
how to call paint method in that click_event
paint();
what arguments will be passed over here


thanks
Posted
Comments
StM0n 16-Feb-12 5:34am    
The method is not ment to be called by the click_event...
What do you want to achieve?

You do not call the Paint method directly - it is normally attached as a handler to the Paint event, and is called automatically when the display element need to be updated.

You can force the framework to signal the Paint event my using the Control.Invalidate() method. For example:
C#
myPanel.Invalidate();
 
Share this answer
 
The paint method can be overridden in classes inheriting from window control (or a descendant of that) and is called automatically when the control is repainted). You could call Repaint directly, but that would be a bad practice because you summon the application that it must execute the repaint, even if it is still busy doing so and already a few calls to it are waiting. This would stall your application and should therefor not be done. You should call Invalidate instead which would repaint the control as soon a possible but without queuing multiple calls and therefor won't stall your application.

It's become quite a story with some extra background information that eventually in short would comes down to... Invalidate

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900