开发者

Painted Border Runs In Certain Situations

开发者 https://www.devze.com 2022-12-20 14:14 出处:网络
In my tool I use a a panel to change pages.Each page has it\'s own panel and when I change a page I send the panel with the controls.On the panel I use as the canvas I have the following paint event:

In my tool I use a a panel to change pages. Each page has it's own panel and when I change a page I send the panel with the controls. On the panel I use as the canvas I have the following paint event:

    private void panelContent_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
        e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

        // Paints a border around the panel to match the treeview control
        e.Graphics.DrawRectangle(Pens.CornflowerBlue,
            e.ClipRectangle.Left,
            e.ClipRectangle.Top,
            e.ClipRectangle.Width - 1,
            e.ClipRectangle.Height - 1);

        e.Graphics.Flush();

        base.OnPaint(e);
    }

This method basically draws a nice border around the panel so it look better. For some reason when I move a another form above this panel the lines that make up the border start to run a little. 开发者_如何学编程 Occasionally small lines will be drawn from the border too. The problem only happens for a few seconds before the entire panel redraws again. Is there anything I can do to prevent this from happening?


ClipRectangle tells you what part of the control needs to be repainted. If you're moving something over it, this is probably going to be the intersection of your object and the one being moved. You can use this information to more efficiently repaint your control.

You probably want to draw the rectangle from (0, 0) to (panelContent.Width-1, panelContent.Height-1).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号