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

TableCellCollection クラス

Table コントロールの行を構成する、TableHeaderCell オブジェクトTableCell オブジェクトコレクションカプセル化ます。このクラス継承できません。

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

Public NotInheritable Class
 TableCellCollection
    Implements IList, ICollection, IEnumerable
Dim instance As TableCellCollection
public sealed class TableCellCollection : IList,
 ICollection, IEnumerable
public ref class TableCellCollection sealed
 : IList, ICollection, IEnumerable
public final class TableCellCollection implements
 IList, ICollection, 
    IEnumerable
public final class TableCellCollection implements
 IList, ICollection, 
    IEnumerable
解説解説
使用例使用例

プログラムによって Table コントロールに値を設定する方法の例を次に示します個別セルを表す TableCell オブジェクトは、Cells プロパティによって、個別の行を表す TableRow オブジェクト追加されます。

<%@ Page Language="VB" AutoEventWireup="True"
 %>

<html>
 <head>
 
    <script runat="server">

        Sub Page_Load(sender As Object,
 e As EventArgs)
            ' Generate rows and cells.           
            Dim numrows As Integer
 = 4
            Dim numcells As Integer
 = 6
            Dim counter As Integer
 = 1
            Dim j As Integer
            For j = 0 To numrows - 1
                Dim r As New
 TableRow()
                Dim i As Integer
                For i = 0 To numcells - 1
                    Dim c As New
 TableCell()
                    c.Text = counter.ToString()
                    counter += 1
                    r.Cells.Add(c)
                Next i
                Table1.Rows.Add(r)
            Next j
        End Sub

        Sub Button_Click_Coord(sender As Object,
 e As EventArgs)            
            Dim i As Integer
            For i = 0 To Table1.Rows.Count
 - 1
                Dim j As Integer
                For j = 0 To (Table1.Rows(i).Cells.Count)
 - 1                    
                    Table1.Rows(i).Cells(j).Text = "("
 & j.ToString() & _
                        ", " & i.ToString() &
 ")"
                Next j
            Next i 
        End Sub

        Sub Button_Click_Number(sender As Object,
 e As EventArgs)
            Dim counter As Integer
 = 1
            
            Dim i As Integer
            For i = 0 To Table1.Rows.Count
 - 1
                Dim j As Integer
                For j = 0 To (Table1.Rows(i).Cells.Count)
 - 1                    
                    Table1.Rows(i).Cells(j).Text = counter.ToString()
                    counter += 1
                Next j 
            Next i
        End Sub
 
    </script>
 
 </head>
 
 <body>
 
    <h3>TableCellCollection Example</h3>
    <form runat="server">
       <asp:Table id="Table1" 
            runat="server"/>
       <br>
       <center>
          <asp:Button id="Button1"
               Text="Display Table Coordinates"
               OnClick="Button_Click_Coord"
               runat="server"/>
          <asp:Button id="Button2"
               Text="Display Cell Numbers"
               OnClick="Button_Click_Number"
               runat="server"/>
       </center>
 
    </form>
 
 </body>
 </html>
    
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
 <head>
 
    <script runat="server">
       void Page_Load(Object sender, EventArgs e) 
       {
          // Generate rows and cells.           
          int numrows = 4;
          int numcells = 6;
          int counter = 1;
          for (int j=0; j<numrows; j++)
 
          {          
             TableRow r = new TableRow();
             for (int i=0; i<numcells; i++)
 
             {
                TableCell c = new TableCell();
                c.Text=counter.ToString();
                counter++;
                r.Cells.Add(c);
             }
             Table1.Rows.Add(r);
          }
       }
 
       void Button_Click_Coord(object sender, EventArgs e) 
       {
          
          for (int i=0; i<Table1.Rows.Count;
 i++) 
          {          
             for (int j=0; j<Table1.Rows[i].Cells.Count;
 j++) 
             {
                
                Table1.Rows[i].Cells[j].Text = "(" + 
                   j.ToString() + ", " + i.ToString() + ")";
                
             }            
          }
 
       }
      
       void Button_Click_Number(object sender, EventArgs e) 
       {
 
          int counter = 1;
          
          for (int i=0; i<Table1.Rows.Count;
 i++) 
          {          
             for (int j=0; j<Table1.Rows[i].Cells.Count;
 j++) 
             {
                
                Table1.Rows[i].Cells[j].Text = counter.ToString();
                counter++;
                
             }            
          }
 
       }
 
    </script>
 
 </head>
 
 <body>
 
    <h3>TableCellCollection Example</h3>
    <form runat="server">
       <asp:Table id="Table1" 
            runat="server"/>
       <br>
       <center>
          <asp:Button id="Button1"
               Text="Display Table Coordinates"
               OnClick="Button_Click_Coord"
               runat="server"/>
          <asp:Button id="Button2"
               Text="Display Cell Numbers"
               OnClick="Button_Click_Number"
               runat="server"/>
       </center>
 
    </form>
 
 </body>
 </html>
    
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.WebControls.TableCellCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「TableCellCollection クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS