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

Dim instance As MenuItemBindingCollection Dim value As MenuItemBinding Dim returnValue As Integer returnValue = instance.IndexOf(value)
戻り値
コレクション内に value が見つかった場合は、最初に見つかった位置の 0 から始まるインデックス番号。それ以外の場合は -1。

IndexOf メソッドを使用して、コレクション内の指定された MenuItemBinding オブジェクトのインデックスを確認します。
![]() |
---|
MenuItemBinding オブジェクトがコレクションに表示される順序は、これらのオブジェクトが Menu コントロールのメニュー項目に適用される方法には影響しません。 |

IndexOf メソッドを使用して、コレクション内の MenuItemBinding オブジェクトのインデックスを確認する方法のコード例を次に示します。この例を正常に動作させるには、以下のサンプル XML データを、Map.xml という名前のファイルにコピーする必要があります。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Use the indexer to retrieve the MenuItemBinding ' object at index 2. Dim binding As MenuItemBinding = NavigationMenu.DataBindings(2) Dim index As Integer = NavigationMenu.DataBindings.IndexOf(binding) Message.Text = "The MenuItemBinding object that is applied " & _ "to the menu items at depth 2 is contained in the Bindings " & _ "collection at index " & index.ToString() & "." End If End Sub </script> <html> <body> <form id="Form1" runat="server"> <h3>MenuItemBindingCollection IndexOf Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" target="_blank" datasourceid="MenuSource" runat="server"> <DataBindings> <asp:menuitembinding datamember="MapHomeNode" depth="0" textfield="title" navigateurlfield="url"/> <asp:menuitembinding datamember="MapNode" depth="1" textfield="title" navigateurlfield="url"/> <asp:menuitembinding datamember="MapNode" depth="2" textfield="title" navigateurlfield="url"/> </DataBindings> </asp:menu> <hr/> <asp:label id="Message" runat="server"/> <asp:xmldatasource id="MenuSource" datafile="Map.xml" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if(!IsPostBack) { // Use the indexer to retrieve the MenuItemBinding // object at index 2. MenuItemBinding binding = NavigationMenu.DataBindings[2]; int index = NavigationMenu.DataBindings.IndexOf(binding); Message.Text = "The MenuItemBinding object that is applied " + "to the menu items at depth 2 is contained in the Bindings " + "collection at index " + index.ToString() + "."; } } </script> <html> <body> <form runat="server"> <h3>MenuItemBindingCollection IndexOf Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" target="_blank" datasourceid="MenuSource" runat="server"> <DataBindings> <asp:menuitembinding datamember="MapHomeNode" depth="0" textfield="title" navigateurlfield="url"/> <asp:menuitembinding datamember="MapNode" depth="1" textfield="title" navigateurlfield="url"/> <asp:menuitembinding datamember="MapNode" depth="2" textfield="title" navigateurlfield="url"/> </DataBindings> </asp:menu> <hr/> <asp:label id="Message" runat="server"/> <asp:xmldatasource id="MenuSource" datafile="Map.xml" runat="server"/> </form> </body> </html>
<MapHomeNode url="~\Home.aspx"
description="Home">
<MapNode url="~\Music.aspx"
description="Music">
<MapNode url="~\Classical.aspx"
description="Classical"/>
<MapNode url="~\Rock.aspx"
description="Rock"/>
<MapNode url="~\Jazz.aspx"
description="Jazz"/>
</MapNode>
<MapNode url="~\Movies.aspx"
<MapNode url="~\Action.aspx"
description="Action"/>
<MapNode url="~\Drama.aspx"
description="Drama"/>
<MapNode url="~\Musical.aspx"
description="Musical"/>
</MapNode>
</MapHomeNode>

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に収録されているすべての辞書からMenuItemBindingCollection.IndexOf メソッドを検索する場合は、下記のリンクをクリックしてください。

- MenuItemBindingCollection.IndexOf メソッドのページへのリンク