如何在更改属性后在设计时刷新winform自定义控件

假设我创建了一个嵌入轨迹栏的自定义控件。 我还为自定义控件创建了一个orientation属性。 当我在表单上删除自定义控件时,默认情况下它将是水平的。 然后我将其设置为垂直,轨迹栏应在设计时刷新为垂直。

怎么办?

我想你应该在更改值后调用Refresh()

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