다음을 통해 공유


FormViewDesigner.GetDesignTimeHtml 메서드

정의

디자인 타임에, 연결된 컨트롤을 렌더링하는 데 사용되는 태그를 가져옵니다.

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

반환

디자인 타임에 FormView을(를) 렌더링하는 데 사용되는 태그가 포함된 String입니다.

예제

다음 코드 예제에서는 재정의 하는 방법을 보여 줍니다.는 GetDesignTimeHtml 에서 상속 된 클래스에서 메서드를 FormViewDesigner 클래스의 모양을 변경 하는 FormView 디자인 타임에 컨트롤입니다. 예제를 포함 하도록 표에 새 첫 번째 행을 추가 합니다 Caption 속성인 경우는 Caption 정의 됩니다. 경우는 BorderStyle 에서 파생 된 컨트롤의 속성을 FormViewNotSet 또는 None 값은 GetDesignTimeHtml 해당 범위 보다 편리 하 게 컨트롤 주변의 파란색 파선된 테두리를 그립니다. 이 예제에서는 컨트롤의 런타임 모양을 변경하지 않습니다.

// Generate the design-time markup.
const string capTag = "caption";
const string trOpen = "tr><td colspan=9 align=center";
const string trClose = "td></tr";

public override string GetDesignTimeHtml()
{
    // Make the full extent of the control more visible in the designer.
    // If the border style is None or NotSet, change the border to
    // a wide, blue, dashed line. Include the caption within the border.
    MyFormView myGV = (MyFormView)Component;
    string markup = null;
    int charX;

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

        // Set the design-time properties and catch any exceptions.
        try
        {
            myGV.BorderStyle = BorderStyle.Dashed;
            myGV.BorderWidth = Unit.Pixel(3);
            myGV.BorderColor = Color.Blue;

            // 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.
            myGV.BorderStyle = oldBorderStyle;
            myGV.BorderWidth = oldBorderWidth;
            myGV.BorderColor = oldBorderColor;
        }
    }
    else
    {
        // Call the base method to generate the markup.
        markup = base.GetDesignTimeHtml();
    }

    // Look for a <caption> tag.
    if ((charX = markup.IndexOf(capTag)) > 0)
    {
        // Replace the first caption with 
        // "tr><td colspan=9 align=center".
        // It is okay if the colspan exceeds the 
        // number of columns in the table.
        markup = markup.Remove(charX,
            capTag.Length).Insert(charX, trOpen);

        // Replace the second caption with "td></tr".
        if ((charX = markup.IndexOf(capTag, charX)) > 0)
            markup = markup.Remove(charX,
                capTag.Length).Insert(charX, trClose);
    }
    return markup;
} // GetDesignTimeHtml
' Generate the design-time markup.
Private Const capTag As String = "caption"
Private Const trOpen As String = "tr><td colspan=9 align=center"
Private Const trClose As String = "td></tr"

Public Overrides Function GetDesignTimeHtml() As String

    ' Make the full extent of the control more visible in the designer.
    ' If the border style is None or NotSet, change the border to
    ' a wide, blue, dashed line. Include the caption within the border.
    Dim myGV As MyFormView = CType(Component, MyFormView)
    Dim markup As String = Nothing
    Dim charX As Integer

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

        Dim oldBorderStyle As BorderStyle = myGV.BorderStyle
        Dim oldBorderWidth As Unit = myGV.BorderWidth
        Dim oldBorderColor As Color = myGV.BorderColor

        ' Set the design-time properties and catch any exceptions.
        Try
            myGV.BorderStyle = BorderStyle.Dashed
            myGV.BorderWidth = Unit.Pixel(3)
            myGV.BorderColor = Color.Blue

            ' 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.
            myGV.BorderStyle = oldBorderStyle
            myGV.BorderWidth = oldBorderWidth
            myGV.BorderColor = oldBorderColor
        End Try

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

    ' Look for a <caption> tag.
    charX = markup.IndexOf(capTag)
    If charX > 0 Then

        ' Replace the first caption with 
        ' "tr><td colspan=9 align=center".
        ' It is okay if the colspan exceeds the 
        ' number of columns in the table.
        markup = markup.Remove(charX, _
            capTag.Length).Insert(charX, trOpen)

        ' Replace the second caption with "td></tr".
        charX = markup.IndexOf(capTag, charX)
        If charX > 0 Then
            markup = markup.Remove(charX, _
                capTag.Length).Insert(charX, trClose)
        End If
    End If

    Return markup

End Function ' GetDesignTimeHtml

설명

컨트롤에 대해 항목 템플릿이 정의된 경우 메서드는 데이터 원본에 대한 FormViewGetDesignTimeHtml 스키마를 가져올 수 없는 경우 컨트롤의 컬렉션을 빈 String 배열로 설정합니다DataKeyNames. 는 GetDesignTimeHtml 메서드를 TypeDescriptor 강제로 호출하도록 개체를 PreFilterProperties 새로 고칩니다. 그런 다음 은 GetDesignTimeHtml 기본 메서드를 호출하여 태그를 생성합니다.

컨트롤 GetDesignTimeHtml 에 대해 FormView 정의된 항목 템플릿이 없는 경우 는 메서드를 GetEmptyDesignTimeHtml 호출하여 자리 표시자에 렌더링되는 태그를 생성합니다.

상속자 참고

메서드를 재정의 GetDesignTimeHtml() 하는 경우 결국 여러 재정의 수준을 통해 컨트롤 또는 컨트롤의 FormView 복사본을 FormView 호출하여 태그를 생성하기 때문에 기본 메서드를 호출해야 합니다.

적용 대상

추가 정보