winfrom Panel 问题

Panel 图片自适应 BackgroundImageLayout 设置成Zoom就行

Panel动态换图片时候的闪烁问题:

首先创建一个自己的panel类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace Test
{
    //开启双缓冲
    class MyPanel:Panel
    {
        public MyPanel()
        {
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
        }
    }

然后重新生成解决方法,就会发现工具箱中多了一个自己写的panel控件,在画图形的时候,画在自己的panel上就可以了。由于自己的panel继承自Panel类,所以Panel中的方法都可以使用。

猜你喜欢

转载自www.cnblogs.com/dxqNet/p/9814857.html