如何刷新在设计时一个WinForm自定义控件更改属性后 [英] How to refresh a winform custom control at design time after changing a property

查看:1724
本文介绍了如何刷新在设计时一个WinForm自定义控件更改属性后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我创建一个嵌入的TrackBar自定义控件。我也给我的自定义控件的取向性。
当我在默认情况下删除一个窗体上自定义控件将是水平的。然后,我将其设置为垂直时,跟踪条应该刷新是在设计时是垂直的。

Let's say I create a custom control which embed a trackbar. I also create an orientation property for my custom control. When I drop the custom control on a form by default it will be horizontal. Then I set it to vertical, the trackbar should refresh to be vertical at design time.

怎么做?

推荐答案

我觉得你应该叫的 刷新() 修改完毕:

I think you should call Refresh() after changing the value:

public OrientationProperty Direction
{
    get
    {
        return _direction;
    }
    set
    {
        _direction = value;
        if (DesignMode)
        {
            Parent.Refresh(); // Refreshes the client area of the parent control
        }
    }
}
private OrientationProperty _direction;

这篇关于如何刷新在设计时一个WinForm自定义控件更改属性后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆