HtmlTableCellCollection.GetEnumerator メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As HtmlTableCellCollection Dim returnValue As IEnumerator returnValue = instance.GetEnumerator
public IEnumerator GetEnumerator ()
public: virtual IEnumerator^ GetEnumerator () sealed
public final IEnumerator GetEnumerator ()
public final function GetEnumerator () : IEnumerator
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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlTableCellCollection.GetEnumerator メソッドを検索する場合は、下記のリンクをクリックしてください。

- HtmlTableCellCollection.GetEnumerator メソッドのページへのリンク