LoginStatusDesigner.GetDesignTimeHtml メソッド

定義

デザイン時に関連付けられたコントロールを描画するために使用するマークアップを取得します。

public:
 override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String

戻り値

デザイン時に LoginStatus を表示するためのマークアップを格納している文字列。

次のコード例は、 クラスから継承されたクラスの メソッドをオーバーライド GetDesignTimeHtml して、デザイン時に クラスから LoginStatusDesigner 派生したコントロールの外観を変更する方法を LoginStatus 示しています。 次の使用例は、コントロールの プロパティが または None 値の場合BorderStyleに、コントロールの周囲に青い破線の境界線をNotSet描画して、その範囲を表示できるようにします。

// Generate the design-time markup.
public override string GetDesignTimeHtml()
{
    // Make the control more visible in the designer.  If the border 
    // style is None or NotSet, change the border to a blue dashed line. 
    MyLoginStatus myLoginStatusCtl = (MyLoginStatus)ViewControl;
    string markup = null;

    // Check if the border style should be changed.
    if (myLoginStatusCtl.BorderStyle == BorderStyle.NotSet ||
        myLoginStatusCtl.BorderStyle == BorderStyle.None)
    {
        BorderStyle oldBorderStyle = myLoginStatusCtl.BorderStyle;
        Color oldBorderColor = myLoginStatusCtl.BorderColor;

        // Set the design time properties and catch any exceptions.
        try
        {
            myLoginStatusCtl.BorderStyle = BorderStyle.Dashed;
            myLoginStatusCtl.BorderColor = Color.Blue;

            // Call the base method to generate the markup.
            markup = base.GetDesignTimeHtml();
        }
        catch (Exception ex)
        {
            markup = GetErrorDesignTimeHtml(ex);
        }
        finally
        {
            // It is not necessary to restore the border properties 
            // to their original values because the ViewControl 
            // was used to reference the associated control and the 
            // UsePreviewControl was not overridden.  

            // myLoginCtl.BorderStyle = oldBorderStyle;
            // myLoginCtl.BorderColor = oldBorderColor;
        }
    }
    else
    {
        // Call the base method to generate the markup.
        markup = base.GetDesignTimeHtml();
    }

    return markup;
} // GetDesignTimeHtml
' Generate the design-time markup.
Public Overrides Function GetDesignTimeHtml() As String

    ' Make the control more visible in the designer.  If the border 
    ' style is None or NotSet, change the border to a blue dashed line. 
    Dim myLoginStatusCtl As MyLoginStatus = _
        CType(ViewControl, MyLoginStatus)
    Dim markup As String = Nothing

    ' Check if the border style should be changed.
    If (myLoginStatusCtl.BorderStyle = BorderStyle.NotSet Or _
        myLoginStatusCtl.BorderStyle = BorderStyle.None) Then

        Dim oldBorderStyle As BorderStyle = myLoginStatusCtl.BorderStyle
        Dim oldBorderColor As Color = myLoginStatusCtl.BorderColor

        ' Set the design time properties and catch any exceptions.
        Try
            myLoginStatusCtl.BorderStyle = BorderStyle.Dashed
            myLoginStatusCtl.BorderColor = Color.Blue

            ' Call the base method to generate the markup.
            markup = MyBase.GetDesignTimeHtml()

        Catch ex As Exception
            markup = GetErrorDesignTimeHtml(ex)

        Finally
            ' It is not necessary to restore the border properties 
            ' to their original values because the ViewControl 
            ' was used to reference the associated control and the 
            ' UsePreviewControl was not overridden.  

            ' myLoginCtl.BorderStyle = oldBorderStyle
            ' myLoginCtl.BorderColor = oldBorderColor
        End Try

    Else
        ' Call the base method to generate the markup.
        markup = MyBase.GetDesignTimeHtml()
    End If

    Return markup

End Function ' GetDesignTimeHtml

注釈

LogoutTextまたは LoginText プロパティ (ユーザーがログインしているかどうかに応じて) が null、空の文字列 ("")、または単一のスペース (" ") GetDesignTimeHtml である場合、メソッドは、 プロパティまたは LoginText プロパティを、必要に応じてプロパティにID設定LogoutTextし、角かっこ ("[ ]") で囲みます。 次に、 または のLoginText設定に関係なく、 メソッドはGetDesignTimeHtml基本メソッドをGetDesignTimeHtml呼び出して、コントロールのデザイン時レンダリング用のマークアップをLoginStatus生成LogoutTextします。

注意 (継承者)

メソッドをオーバーライドする GetDesignTimeHtml() 場合は、最終的に複数の GetDesignTimeHtml() オーバーライド レベルを介して、コントロールまたはコントロールのコピーを呼び出してマークアップを生成するため、基本メソッドを呼び出 LoginStatus してください。

適用対象

こちらもご覧ください