HtmlTableCellCollection.CopyTo メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HtmlTableCellCollection.CopyTo メソッドの意味・解説 

HtmlTableCellCollection.CopyTo メソッド

HtmlTableCellCollection コレクションから、指定した System.Array に項目をコピーしますコピーSystem.Array 内の指定されインデックス位置から開始します

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

Dim instance As HtmlTableCellCollection
Dim array As Array
Dim index As Integer

instance.CopyTo(array, index)

パラメータ

array

HtmlTableCellCollection の項目のコピー先となる、インデックス番号が 0 から始まる System.Array。

index

項目のコピー先として指定されている System.Array最初インデックス

解説解説
使用例使用例

CopyTo メソッド使用してHtmlTableCellCollection コレクションと同じ内容格納する配列作成する方法次のコード例示しますその後配列反復処理され、HtmlTableCellCollection コレクション内容表示されます。

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

<script runat="server">

  Sub Button_Click(ByVal sender As
 Object, ByVal e As EventArgs)
 
    Dim myCellArray(1) As HtmlTableCell
    Dim cell As HtmlTableCell
 
    ' Copy the collection to an array.
    Table1.Rows(0).Cells.CopyTo(myCellArray, 0)
 
    Span1.InnerText = "The copied items from the selected row
 are: "

    ' Iterate through the array and display its contents.
    For Each cell In myCellArray
         
      Span1.InnerText = Span1.InnerText & " "
 & cell.InnerText
 
    Next cell

  End Sub

</script>

<html>
<head>
   <title>HtmlTableCellCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCellCollection Example</h3>

      <table id="Table1" 
             border="1" 
             bordercolor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>
         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>

      <br><br>
  
      <input type="button" 
             value="Display the contents of the first row"
             onserverclick="Button_Click" 
             runat="server"/>

      <br><br>

      <span id="Span1"
            runat="server"/>

   </form>

</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>

<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    HtmlTableCell[] myCellArray = new HtmlTableCell[2];

    // Copy the collection to an array.
    Table1.Rows[0].Cells.CopyTo(myCellArray, 0);

    Span1.InnerText = "The copied items from the selected row are: ";

    // Iterate through the array and display its contents.
    foreach (HtmlTableCell cell in myCellArray)
    {

      Span1.InnerText = Span1.InnerText + " " + cell.InnerText;

    }

  }

</script>

<html>
<head>
   <title>HtmlTableCellCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCellCollection Example</h3>

      <table id="Table1" 
             border="1" 
             bordercolor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>
         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>

      <br><br>
  
      <input type="button" 
             value="Display the contents of the first row"
             onserverclick="Button_Click" 
             runat="server"/>

      <br><br>

      <span id="Span1"
            runat="server"/>

   </form>

</body>
</html>
<%@ Page Language="JScript" AutoEventWireup="True" %>

<script runat="server">

  function Button_Click(sender, e : EventArgs) 
  {
 
     var myCellArray : HtmlTableCell[] = new
 HtmlTableCell[2];
 
     // Copy the collection to an array.
     Table1.Rows[0].Cells.CopyTo(myCellArray, 0);      

     Span1.InnerText = "The copied items from the selected row are: ";

     // Iterate through the array and display its contents.
     for (var i : int in
 myCellArray) 
     {
         
        Span1.InnerText = Span1.InnerText + " " + myCellArray[i].InnerText;
 
     }

  }

</script>

<html>
<head>
   <title>HtmlTableCellCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCellCollection Example</h3>

      <table id="Table1" 
             border="1" 
             bordercolor="black" 
             runat="server">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>
         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>

      <br><br>
  
      <input type="button" 
             value="Display the contents of the first row"
             onserverclick="Button_Click" 
             runat="server"/>

      <br><br>

      <span id="Span1"
            runat="server"/>

   </form>

</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlTableCellCollection クラス
HtmlTableCellCollection メンバ
System.Web.UI.HtmlControls 名前空間
System.Array



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

辞書ショートカット

すべての辞書の索引

HtmlTableCellCollection.CopyTo メソッドのお隣キーワード
検索ランキング

   

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



HtmlTableCellCollection.CopyTo メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS