TableDesigner クラスとは? わかりやすく解説

TableDesigner クラス

Table Web サーバー コントロールデザイン時の動作拡張します。

名前空間: System.Web.UI.Design.WebControls
アセンブリ: System.Design (system.design.dll 内)
構文構文

Public Class TableDesigner
    Inherits ControlDesigner
Dim instance As TableDesigner
public class TableDesigner : ControlDesigner
public ref class TableDesigner : public
 ControlDesigner
public class TableDesigner extends ControlDesigner
public class TableDesigner extends
 ControlDesigner
使用例使用例

このセクションには、2 つコード例含まれています。最初コード例では、TableDesigner クラスからクラス派生する方法示します2 番目のコード例では、デザイン時に StyledTable クラス表示する方法示します

StyledTableDesigner という名前のデザイナ クラスTableDesigner クラスから派生して作成する方法次のコード例示します。このクラスは、デザイン時にTable クラスから派生したクラス2 つセル表示するために使用されます。

' Create a class, named StyledTableDesigner,
' that derives from the TableDesigner class.
' This class displays a class named StyledTable
' at design time.
Public Class StyledTableDesigner
   Inherits TableDesigner
   
   ' 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

End Class

DesignerAttribute使用して StyledTableDesigner クラスStyledTable クラス関連付けデザイン時に表示されるようにするコード例次に示します

 ' Create a class that uses the StyledTableDesigner
 ' class to display its contents at design time.
<Designer("Examples.AspNet.Design.StyledTableDesigner",
 "TableDesigner")> _
Public Class StyledTable
  Inherits Table 
    

    Private tableStyle As Style = New
 Style()
    
    Public Sub New()
       tableStyle.BackColor = Color.LightBlue
       tableStyle.BorderColor = Color.Black
       
       CellSpacing = 4
       CellPadding = 0
       GridLines = GridLines.None
       BorderWidth = Unit.Point(1)
       Width = Unit.Percentage(100)
       Height = Unit.Percentage(100)

    End Sub
End Class
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
        System.Web.UI.Design.WebControls.TableDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TableDesigner メンバ
System.Web.UI.Design.WebControls 名前空間
Table



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TableDesigner クラス」の関連用語

TableDesigner クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TableDesigner クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS