小编Ber*_*ker的帖子

如何在设计视图中为自定义控件添加边框?

透明图像在Windows窗体中是纯粹的邪恶,这就是为什么我创建了一个自定义控件类来处理它们.设计师在空的时候不显示我的控制权.我想添加一个微妙的边框,但只在设计视图中(当用户没有添加边框时).我该怎么做?

我的班级是:

class TransparentImage : Control
{
    public Image Image { get; set; }

    protected Graphics graphics;

    public string FilePath { get; set; }

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT

            return cp;
        }
    }

    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
        // Don't paint background
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        // Update the private member so we can use it in the OnDraw method
        this.graphics = e.Graphics;

        // Set the …
Run Code Online (Sandbox Code Playgroud)

.net c# visual-studio winforms

5
推荐指数
1
解决办法
484
查看次数

标签 统计

.net ×1

c# ×1

visual-studio ×1

winforms ×1