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

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

HtmlTableRowCollection.GetEnumerator メソッド

HtmlTableRowCollection コレクションすべての HtmlTableRow オブジェクト格納する System.Collections.IEnumerator 実装オブジェクト返します

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

Public Function GetEnumerator As
 IEnumerator
Dim instance As HtmlTableRowCollection
Dim returnValue As IEnumerator

returnValue = instance.GetEnumerator

戻り値
HtmlTableRowCollectionすべての HtmlTableRow オブジェクト格納する System.Collections.IEnumerator 実装オブジェクト

解説解説

このメソッド使用してHtmlTableRowCollection コレクションの各項目を取得する場合反復処理できる System.Collections.IEnumerator 実装オブジェクト作成します

IEnumerator.Current プロパティ使用してコレクション内の現在の要素取得します

IEnumerator.MoveNext メソッド使用してコレクション内の次の項目に移動します

IEnumerator.Reset メソッド使用して列挙子を最初位置移動します

メモメモ

System.Collections.IEnumerator 実装オブジェクトの作成後または IEnumerator.Reset メソッド使用後IEnumerator.MoveNext メソッド呼び出して列挙子をコレクション最初の項目に移動する必要があります。このメソッド呼び出さないと、IEnumerator.Current プロパティ表される項目は未定義になります

使用例使用例

GetEnumerator メソッド使用してSystem.Collections.IEnumerator オブジェクト作成する方法次のコード例示しますその後System.Collections.IEnumerator オブジェクト反復処理され、HtmlTableRowCollection コレクション内容表示されます。

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

<script runat="server">

  Sub Button_Click(ByVal sender As
 Object, ByVal e As EventArgs)
 
    Dim current_row As HtmlTableRow

    ' Create an IEnumerator enumerator.
    Dim myEnum As IEnumerator = Table1.Rows.GetEnumerator()

    Span1.InnerText = "The items in the rows of the table are:
 "

    ' Iterate through the IEnumerator and display its contents.
    While myEnum.MoveNext()
         
      current_row = CType(myEnum.Current, HtmlTableRow)
      Span1.InnerText = Span1.InnerText & " "
 & current_row.Cells(0).InnerText & _
                        " " & current_row.Cells(1).InnerText

    End While

  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 current_row;

    // Create an IEnumerator enumerator.
    IEnumerator myEnum = Table1.Rows.GetEnumerator();

    Span1.InnerText = "The items in the rows of the table
 are: ";

    // Iterate through the IEnumerator and display its contents.
    while (myEnum.MoveNext())
    {

      current_row = (HtmlTableRow)myEnum.Current;
      Span1.InnerText = Span1.InnerText + " " + current_row.Cells[0].InnerText
 +
                        " " + current_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 current_row : HtmlTableRow;

    // Create an IEnumerator enumerator.
    var myEnum : IEnumerator = Table1.Rows.GetEnumerator();  
    

    Span1.InnerText = "The items in the rows of the table are: ";

    // Iterate through the IEnumerator and display its contents.
    while (myEnum.MoveNext()) 
    {
         
      current_row = HtmlTableRow(myEnum.Current);
      Span1.InnerText = Span1.InnerText + " " + current_row.Cells[0].InnerText
 +
                        " " + current_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>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlTableRowCollection クラス
HtmlTableRowCollection メンバ
System.Web.UI.HtmlControls 名前空間
System.Collections.IEnumerator
HtmlTableRow クラス
IEnumerator.Current
IEnumerator.MoveNext
IEnumerator.Reset



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS