| |

VerySource

 Forgot password?
 Register
Search
View: 1181|Reply: 7

Drawing problems!

[Copy link]

3

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-28 15:00:01
| Show all posts |Read mode
Can drawing only be done in the Paint event? What should I do if I write a function to draw on a graphical interface or form?
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-3 15:15:02
| Show all posts
Don't know how to answer!
when&where&how!
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-3 20:15:01
| Show all posts
string text2 = "Draw text in a rectangle by passing a RectF to the DrawString method.";
using (Font font2 = new Font ("Arial", 12, FontStyle.Bold, GraphicsUnit.Point))
{
    Rectangle rect2 = new Rectangle (30, 10, 100, 122);

    // Specify the text is wrapped.
    TextFormatFlags flags = TextFormatFlags.WordBreak;
    TextRenderer.DrawText (e.Graphics, text2, font2, rect2, Color.Blue, flags);
    e.Graphics.DrawRectangle (Pens.Black, Rectangle.Round (rect2));

}
Reply

Use magic Report

1

Threads

31

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-3-4 12:00:02
| Show all posts
You can use the current form to create Graphics for drawing:
Graphics g = this.CreateGraphics ();
Graphics g = Graphics.FromHwnd (this.Handle);

You can also use an Image to create Graphics drawings:
Graphics g = Graphics.FromImage (image);
Reply

Use magic Report

0

Threads

12

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-3-5 08:00:02
| Show all posts
Yes in Paint event, other events are also available.
Reply

Use magic Report

3

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-3-13 12:00:01
| Show all posts
Maybe I'm not too explicit.
What I want to know is how to make g Fouge a specific drawing object. I draw in the paint event. I want to write a function call form, such as drawing in picturebox or other containers.
393736105's answer should be possible, thank you
Reply

Use magic Report

1

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-2 09:30:01
| Show all posts
Write function

First define a picture

A picturebox calls this picture

Use picturebox to generate drawing objects. Draw on the picture. After drawing, refresh the picturebox and the picture will be displayed.

And there is no need to redraw the form anymore
Reply

Use magic Report

2

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-7-9 18:15:01
| Show all posts
Help top!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list