ControlDesigner.UpdateDesignTimeHtml 方法

定义

通过调用 GetDesignTimeHtml 方法刷新关联 Web 服务器控件的设计时 HTML 标记。

public:
 virtual void UpdateDesignTimeHtml();
public virtual void UpdateDesignTimeHtml ();
abstract member UpdateDesignTimeHtml : unit -> unit
override this.UpdateDesignTimeHtml : unit -> unit
Public Overridable Sub UpdateDesignTimeHtml ()

示例

下面的代码示例演示如何响应 Click 控件设计器中的 事件,以更改多区域控件中区域之间的焦点,并使用 UpdateDesignTimeHtml 方法更新设计宿主中控件的外观。

此代码示例是 类的较大示例的 EditableDesignerRegion 一部分。

// Handler for the Click event, which provides the region in the arguments.
protected override void OnClick(DesignerRegionMouseEventArgs e)
{
    if (e.Region == null)
        return;

    // If the clicked region is not a header, return
    if (e.Region.Name.IndexOf("Header") != 0)
        return;

    // Switch the current view if required
    if (e.Region.Name.Substring(6, 1) != myControl.CurrentView.ToString())
    {
        myControl.CurrentView = int.Parse(e.Region.Name.Substring(6, 1));
        base.UpdateDesignTimeHtml();
    }
}
' Handler for the Click event, which provides the region in the arguments.
Protected Overrides Sub OnClick(ByVal e As DesignerRegionMouseEventArgs)
    If IsNothing(e.Region) Then
        Return
    End If

    ' If the clicked region is not a header, return
    If e.Region.Name.IndexOf("Header") <> 0 Then
        Return
    End If

    ' Switch the current view if required
    If e.Region.Name.Substring(6, 1) <> myControl.CurrentView.ToString() Then
        myControl.CurrentView = Integer.Parse(e.Region.Name.Substring(6, 1))
        MyBase.UpdateDesignTimeHtml()
    End If
End Sub

注解

设计 UpdateDesignTimeHtml 宿主调用 方法,以在设计时(例如修改控件时)更新关联 Web 服务器控件的显示。 此外,控件设计器可以在修改控件的值后调用 UpdateDesignTimeHtml 方法,以更新控件的显示。

注意

如果要调用 ComponentChanged 事件或使用 PropertyDescriptor 对象来设置属性,接口会 IComponentChangeService 为你调用 UpdateDesignTimeHtml 方法。

适用于

另请参阅