i have a simple WinForms app which paints some colored rectangles. however when the window is resized it is not correctly updating.
already tried to overwrite OnResize
protected override void OnResize(EventArgs e)
{
repaintingMyStuffHere();
}
try this:
protected override void OnResize(EventArgs e)
{
this.Invalidate();
base.OnResize(e);
}
protected override void OnPaint(PaintEventArgs e) {
{
base.OnPaint(e);
repaintingMyStuffHere(e.Graphics);
}
if you still have the problem try to set the folowing controlstyles:
public MyClass() {
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.ResizeRedraw |
ControlStyles.UserPaint |
ControlStyles.ResizeRedraw,
true);
}
if you still have any problems please post your repaintingMyStuffHere methode.
To get your form/component to render property, and help improve performance, you would need to first override the OnResize()
method to cause it to invalidate the form/component:
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
this.Invalidate();
}
Then (optional, but recommended to reduce flickering) set the form/component DoubleBuffered
property to true:
this.DoubleBuffered = true;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.