MenuDesigner.GetDesignTimeHtml Yöntem

Tanım

Tasarım zamanında ilişkili denetimi işlemek için kullanılan işaretlemeyi 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

Tasarım zamanında işlemek için kullanılan işaretlemeyi Menu içeren bir dize.

Örnekler

Aşağıdaki kod örneği, sınıfından devralınan GetDesignTimeHtmlMenuDesigner bir sınıfta yönteminin nasıl geçersiz kılındığını gösterir. Geçersiz kılınan yöntem, tasarım zamanında denetimden türetilen bir denetimin Menu görünümünü değiştirir. Örnek, denetimin özelliği veya değeriyseBorderStyle, kapsamını daha görünür hale getirmek için denetimin çevresine turuncu, noktalı bir kenarlık çizerNotSet.None

// 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 an orange dotted line. 
    MyMenu myMenuCtl = (MyMenu)ViewControl;
    string markup = null;

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

        // Set the design-time properties and catch any exceptions.
        try
        {
            myMenuCtl.BorderStyle = BorderStyle.Dotted;
            myMenuCtl.BorderColor = Color.FromArgb(0xFF7F00);

            // Call the base method to generate the markup.
            markup = base.GetDesignTimeHtml();
        }
        catch (Exception ex)
        {
            markup = GetErrorDesignTimeHtml(ex);
        }
        finally
        {
            // Restore the properties to their original settings.
            myMenuCtl.BorderStyle = oldBorderStyle;
            myMenuCtl.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 an orange dotted line. 
    Dim myMenuCtl As MyMenu = CType(ViewControl, MyMenu)
    Dim markup As String = Nothing

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

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

        ' Set the design-time properties and catch any exceptions.
        Try
            myMenuCtl.BorderStyle = BorderStyle.Dotted
            myMenuCtl.BorderColor = Color.FromArgb(&HFF7F00)

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

        Catch ex As Exception
            markup = GetErrorDesignTimeHtml(ex)

        Finally
            ' Restore the properties to their original settings.
            myMenuCtl.BorderStyle = oldBorderStyle
            myMenuCtl.BorderColor = oldBorderColor
        End Try

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

    Return markup

End Function ' GetDesignTimeHtml

Açıklamalar

GetDesignTimeHtml yöntemi, tasarım zamanı veri kaynağını ilişkili Menu denetime bağlamak için yöntemini çağırır DataBind ve ardından GetDesignTimeHtml denetimin Menu statik görünümü ve dinamik görünüm işaretlemesini oluşturmasına neden olmak için yöntemini çağırırGetDesignModeState. geçerli GetDesignTimeHtml görünüm için işaretlemeyi döndürür. Geçerli görünüm tanımlanmamışsa, GetDesignTimeHtml temel yöntemi çağırır GetDesignTimeHtml .

Şunlara uygulanır

Ayrıca bkz.