c# - PictureBox resize & paint problem -


I want to show some graphics in a Winform app, it will be chart chart drawing tool. I think (but I'm not sure ...) I have to use the picturebox, and have to use the system. Drawing. Antique illustration to attract graphic class' charts. I have started coding it, now it works more or less, but I have a problem with the resizing feature, as follows: When I change the shape of the whole form, then I think the program shows the graphics , Then he immediately clears it when I stop the mouse movement (without leaving the mouse button) then the graphics disappear !!!?

I created a small test environment to demo the bug: Using VS2005, to create a new C # Windows Form App, just add a picture box in the form Picture Box Anchor is left, up, Setting both the right and the bottom, the two event handlers, the size of the picture box, and paint the form.

  Nameslot PictureBox_Resize {public partial class} form 1: form {public form 1 () {InitializeComponent (); Ellipse_Area = this.pictureBox1.Size; } Private Pen Penblack = New Pen (Color Black, 1.0 F); Private size alipa_arria; Private Zero Form 1_Paint (Object Sender, Paint Event ARG E) {Graphics G = This Picture Box 1 Credigraphics (); G. Drylipes (Penblack, 0, 0, Elypus_Airia Width, Elypus_Aria.High); } Private zero imagebox 1_size (object sender, eventAgps E) {control control = (control) sender; Ellipse_Area = control.Size; This.pictureBox1.Invalidate (); }}  

}

} This small app shows the problem, it only pulls an oval, but of course my drawing code is more complex ...

Any idea why the oval disappears when I change the size of the form ????

Why are you using a PictureBox ? I will create a UserControl for your chart and will draw the oval in my paint method using its current shape, in its manufacturer, for all the painting in double buffering and paint method set it.

  this.SetStyle (ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);  

Comments