Aracılığıyla paylaş


ListControlDesigner.GetDesignTimeHtml Yöntem

Tanım

Tasarım zamanında denetimi temsil etmek için kullanılan HTML'yi alır.

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

Döndürülenler

String Tasarım zamanında'dan türetilen denetimi işlemek için kullanılan işaretlemeyi ListControl içeren.

Örnekler

Aşağıdaki kod örneği, bir tasarım yüzeyinde ilişkili denetim için görüntülenen işaretlemeyi özelleştirmek için yöntemini geçersiz kılar GetDesignTimeHtml . BackColor özelliği ilişkili denetim için tanımlanmamışsa, olarak ayarlanır Gainsborove denetim bu arka plan rengiyle görüntülenir. Bu yapıldıktan sonra yönteminin GetDesignTimeHtml temel uygulaması çağrılır.

Bu kod örneği, sınıfı için ListControlDesigner sağlanan daha büyük bir örneğin parçasıdır.

// 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

Açıklamalar

Nesneden ListControl türetilen ilişkili denetim veriye bağlıysa, GetDesignTimeHtml yöntemi koleksiyonu temizler Items ve denetimin veriye bağlı olduğunu belirten bir String ileti ekler. İlişkili denetim veriye bağlı değilse ve Items koleksiyon boşsa, GetDesignTimeHtml denetimin ilişkisiz olduğunu belirten bir String ileti ekler. Ardından, GetDesignTimeHtml işaretlemeyi oluşturmak için temel yöntemini çağırır.

Şunlara uygulanır

Ayrıca bkz.