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

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

HtmlTableRowCollection.CopyTo メソッド

指定した System.Array オブジェクトHtmlTableRowCollection コレクションの項目をコピーしますコピー操作は、配列内の指定したインデックス位置から始まります

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

Dim instance As HtmlTableRowCollection
Dim array As Array
Dim index As Integer

instance.CopyTo(array, index)

パラメータ

array

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

index

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

解説解説
使用例使用例

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

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

<script runat="server">

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

    ' Iterate through the array and display its contents.
    For Each row In myRowArray
         
      Span1.InnerText = Span1.InnerText & " "
 & row.Cells(0).InnerText & _
                        " " & row.Cells(1).InnerText
 
    Next row

  End Sub

</script>

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

   <form runat="server">

      <h3>HtmlTableRowCollection 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 row contents in the table"
             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)
  {

    HtmlTableRow[] myRowArray = new HtmlTableRow[2];

    // Copy the collection to an array.
    Table1.Rows.CopyTo(myRowArray, 0);

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

    // Iterate through the array and display its contents.
    foreach (HtmlTableRow row in myRowArray)
    {

      Span1.InnerText = Span1.InnerText + " " + row.Cells[0].InnerText
 +
                        " " + row.Cells[1].InnerText;

    }

  }

</script>

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

   <form runat="server">

      <h3>HtmlTableRowCollection 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 row contents in the table"
             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 myRowArray : HtmlTableRow[] = new HtmlTableRow[2];
 
    // Copy the collection to an array.
    Table1.Rows.CopyTo(myRowArray, 0);      
 
    Span1.InnerText = "The copied items from the selected row are: ";

    // Iterate through the array and display its contents.
    for (var i : int = 0;
 i < 2; i ++ ) 
    {
         
       Span1.InnerText = Span1.InnerText + " " + myRowArray[i].Cells[0].InnerText
 + 
                         " " + myRowArray[i].Cells[1].InnerText;
 
    }

  }

</script>


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

   <form runat="server">

      <h3>HtmlTableRowCollection 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 row contents in the table"
             onserverclick = "Button_Click" 
             runat="server"/>

      <br><br>

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

   </form>

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



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS