TableDesigner.GetDesignTimeHtml 메서드

정의

디자인 타임에 컨트롤을 나타내는 데 사용되는 HTML을 가져옵니다.

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

반품

디자인 타임에 컨트롤을 나타내는 데 사용되는 HTML입니다.

예제

다음 코드 예제에서는 디자인 화면에 클래스에 GetDesignTimeHtml 대 한 행 및 셀을 표시 하는 메서드를 재정의 StyledTable 하는 방법을 보여 줍니다. 블록에서 Try 코드는 표에 행 또는 셀이 포함되어 있는지 여부를 확인하고, 행이 없는 경우 행을 만들고 디자인 타임에 각 셀에 표시할 자리 표시자 텍스트와 함께 행에 대한 두 개의 셀을 만드는 루프를 수행합니다. 테이블이 비어 있지 않지만 행이 있는 경우 코드는 동일한 루프를 수행하여 셀을 만들고 채웁니다. 블록에서 Finally 코드는 값을 원래 상태로 반환합니다.

' Override the GetDesignTimeHtml method to display
' placeholder text at design time for the 
' rows and cells of the StyledTable class.
Public Overrides Function GetDesignTimeHtml() As String
    Dim sTable As StyledTable = CType(Component, StyledTable)
    Dim designTimeHTML As String
    Dim rows As TableRowCollection = sTable.Rows
    Dim cellsWithDummyContents As ArrayList = Nothing
   
    Dim emptyTable As Boolean = rows.Count = 0
    Dim emptyRows As Boolean = False
    Dim counter As Integer = 1
    Dim numcells As Integer = 2
    
    Try     
        ' Create two cells to display
        ' in a row at design time.
        If emptyTable Then
            Dim row As TableRow = New TableRow()
            rows.Add(row)
      
            Dim i As Integer
            For i = 0 To numcells - 1
                Dim c As TableCell = New TableCell()
                c.Text = "Cell #" & counter.ToString()
                counter += 1
                rows(0).Cells.Add(c)
            Next i
        Else
            emptyRows = True
            Dim j As Integer
            For j = 0 To rows.Count - 1
                If rows(j).Cells.Count <> 0 Then
                    emptyRows = False
                    Exit For
                End If
            Next j
            If emptyRows = True Then
                Dim k As Integer
                For k = 0 To numcells - 1
                    Dim c As TableCell = New TableCell()
                    c.Text = "Cell #" & counter.ToString()
                    counter += 1
                    rows(0).Cells.Add(c)
                Next k
             End If
        End If
   
        If emptyTable = False Then
            ' If the rows and cells were defined by the user, but the
            ' cells remain empty this code defines a string to display 
            ' in them at design time.
            Dim row As TableRow
            For Each row In rows
                Dim c As TableCell
                For Each c In row.Cells
                    If ((c.Text.Length = 0) AndAlso (c.HasControls() = False)) Then
                       If cellsWithDummyContents Is Nothing Then
                           cellsWithDummyContents = New ArrayList()
                       End If
                       cellsWithDummyContents.Add(c)
                       c.Text = "Cell #" & counter.ToString()
                       counter += 1
                    End If
                Next c
            Next row
        End If
        ' Retrieve the design-time HTML for the StyledTable class.
        designTimeHTML = MyBase.GetDesignTimeHtml()

    Finally
        ' If the StyledTable was empty before the dummy text was added,
        ' restore it to that state.
        If emptyTable Then
            rows.Clear()
        Else
            ' Clear the cells that were empty before the dummy text 
            ' was added.
            If Not (cellsWithDummyContents Is Nothing) Then
                Dim c As TableCell
                For Each c In  cellsWithDummyContents
                    c.Text = [String].Empty
                Next c
            End If
            If emptyRows Then
                rows(0).Cells.Clear()
            End If
        End If
   
    End Try
    Return designTimeHTML
End Function

설명

이 메서드는 GetDesignTimeHtml 표에 행과 셀이 하나 이상 있고 디자인 타임에 표시할 텍스트가 셀에 포함되어 있는지 확인합니다.

적용 대상

추가 정보