ListControlDesigner.GetDesignTimeHtml メソッド

定義

デザイン時にコントロールを表すために使用される HTML を取得します。

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

戻り値

String から派生したコントロールをデザイン時に表示するためのマークアップを格納する ListControl

次のコード例では、 メソッドを GetDesignTimeHtml オーバーライドして、デザイン サーフェイス上の関連付けられたコントロールに対して表示されるマークアップをカスタマイズします。 関連付けられたコントロールに BackColor 対して プロパティが定義されていない場合は、 に Gainsboro設定され、その背景色でコントロールが表示されます。 これが完了すると、 メソッドの GetDesignTimeHtml 基本実装が呼び出されます。

このコード例は、ListControlDesigner クラスのために提供されている大規模な例の一部です。

// Create the markup to display the control on the design surface. 
public override string GetDesignTimeHtml()
{
    string designTimeMarkup = null;

    // Create variables to access the control
    // item collection and back color.
    ListItemCollection items = simpleRadioButtonList.Items;
    Color oldBackColor = simpleRadioButtonList.BackColor;

    // Check the property values and render the markup
    // on the design surface accordingly.
    try
    {
        if (oldBackColor == Color.Empty)
            simpleRadioButtonList.BackColor = Color.Gainsboro;

        if (changedDataSource)
            items.Add("Updated to a new data source: " + 
                DataSource + ".");

        // Call the base method to generate the markup.
        designTimeMarkup = base.GetDesignTimeHtml();
    }
    catch (Exception ex)
    {
        // Catch any exceptions that occur.
        designTimeMarkup = GetErrorDesignTimeHtml(ex);
    }
    finally
    {
        // Set the properties back to their original state.
        simpleRadioButtonList.BackColor = oldBackColor;
        items.Clear();
    }

    return designTimeMarkup;
} // GetDesignTimeHtml
' Create the markup to display the control on the design surface.
Public Overrides Function GetDesignTimeHtml() As String

    Dim designTimeHtml As String = String.Empty

    ' Create variables to access the control's
    ' item collection and back color. 
    Dim items As ListItemCollection = simpleRadioButtonList.Items
    Dim oldBackColor As Color = simpleRadioButtonList.BackColor

    ' Check the property values and render the markup
    ' on the design surface accordingly.
    Try
        If (Color.op_Equality(oldBackColor, Color.Empty)) Then
            simpleRadioButtonList.BackColor = Color.Gainsboro
        End If

        If (changedDataSource) Then
            items.Add( _
                "Updated to a new data source: " & DataSource & ".")
        End If

        designTimeHtml = MyBase.GetDesignTimeHtml()

    Catch ex As Exception
        ' Catch any exceptions that occur.
        MyBase.GetErrorDesignTimeHtml(ex)

    Finally
        ' Set the properties back to their original state.
        simpleRadioButtonList.BackColor = oldBackColor
        items.Clear()
    End Try

    Return designTimeHtml
End Function ' GetDesignTimeHtml

注釈

オブジェクトからListControl派生した関連付けられたコントロールがデータ バインドされている場合、 メソッドはコレクションをItemsクリアし、GetDesignTimeHtmlコントロールがデータ バインドであることを示すメッセージを追加Stringします。 関連付けられたコントロールがデータ バインドされておらず、 Items コレクションが空の場合、 GetDesignTimeHtml はコントロールがバインドされていないことを示すメッセージを追加 String します。 次に、 はその GetDesignTimeHtml 基本メソッドを呼び出してマークアップを生成します。

適用対象

こちらもご覧ください