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

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

HtmlTableCellCollection.GetEnumerator メソッド

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

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

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

returnValue = instance.GetEnumerator

戻り値
HtmlTableCellCollectionすべての HtmlTableCell オブジェクト格納している System.Collections.IEnumerator 実装オブジェクト

解説解説

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

IEnumerator.Current プロパティ使用してコレクション内で現在ポインタ指している項目を取得します

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

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

メモメモ

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

使用例使用例

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

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

<script runat="server">
  
  Sub Button_Click(ByVal sender As
 Object, ByVal e As EventArgs)
 
    Dim current_cell As HtmlTableCell

    ' Create an IEnumerator instance.
    Dim myEnum As IEnumerator = Table1.Rows(0).Cells.GetEnumerator()

    Span1.InnerText = "The items in the first row are: "

    ' Iterate through the IEnumerator and display its contents.
    While myEnum.MoveNext()
         
      current_cell = CType(myEnum.Current, HtmlTableCell)
      Span1.InnerText = Span1.InnerText & " "
 & current_cell.InnerText

    End While

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

    // Create an IEnumerator instance.
    IEnumerator myEnum = Table1.Rows[0].Cells.GetEnumerator();

    Span1.InnerText = "The items in the first row are: ";

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

      current_cell = (HtmlTableCell)myEnum.Current;
      Span1.InnerText = Span1.InnerText + " " + current_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 current_cell : HtmlTableCell;

     // Create an IEnumerator instance.
     var myEnum : IEnumerator = Table1.Rows[0].Cells.GetEnumerator();
      

     Span1.InnerText = "The items in the first row are: ";

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


このページでは「.NET Framework クラス ライブラリ リファレンス」からHtmlTableCellCollection.GetEnumerator メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHtmlTableCellCollection.GetEnumerator メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHtmlTableCellCollection.GetEnumerator メソッド を検索

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS