MenuItem.ValuePath プロパティ
アセンブリ: System.Web (system.web.dll 内)


ValuePath プロパティは、ルート メニュー項目から現在のメニュー項目までのパスを構成するメニュー項目の値のコンマ区切りのリストを格納します。値パスは、Menu コントロール内でのメニュー項目の位置を示すために使用されます。メニュー項目の値を区切るための区切り文字は、PathSeparator プロパティを使用して指定できます。通常この値は、個々の値についてリストを解析する場合や、TreeView クラスの FindItem メソッドに引数として渡す場合に使用されます。Menu コントロールに表示される値によっては、競合を防ぐために区切り文字を変更する必要があります。たとえば、区切り文字をコンマに設定した場合は、表示値にコンマを入れないでください。コンマを入れると、ValuePath プロパティを正確に解析できません。
![]() |
---|
ルート メニュー項目から現在のメニュー項目までの間の各メニュー項目の Value プロパティの値を使用して、値パスを生成します。同じメニュー レベルにあるメニュー項目は、それぞれの Value プロパティの値が一意であることが必要です。同一レベルの複数のメニュー項目でこの値が同じであると、Menu コントロールは各メニュー項目を区別できません。 |

値を解析して、個々のメニュー項目の値の ValuePath プロパティに設定する方法のコード例を次に示します。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' Get the Classical menu item using the Items ' and ChildItems collections. Dim item As MenuItem = NavigationMenu.Items(0).ChildItems(0).ChildItems(0) ' Create the delimiter array using the PathSeparator value. ' This array is used by the the Split method to parse the ' value path string. Dim DelimiterArray(1) As Char DelimiterArray(0) = NavigationMenu.PathSeparator ' Parse the value path of the Classical menu item ' using the Split method. Dim nodeValues() As String = item.ValuePath.Split(DelimiterArray) ' Display the original and parsed values. Message.Text = "The original value path for the Classical menu item is <b>" & _ item.ValuePath & "</b>.<br/>" Message.Text &= "The individual values that make up the value " & _ "path are: <br/>" Dim menuValue As String For Each menuValue In nodeValues Message.Text &= "- <b>" & menuValue & "</b><br/>" Next End Sub </script> <html> <body> <form runat="server"> <h3>MenuItem ValuePath Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="1" staticsubmenuindent="10" orientation="Vertical" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> <hr/> <asp:label id="Message" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Get the Classical menu item using the Items // and ChildItems collections. MenuItem item = NavigationMenu.Items[0].ChildItems[0].ChildItems[0]; // Create the delimiter array using the PathSeparator value. // This array is used by the the Split method to parse the // value path string. Char[] DelimiterArray = new Char[1]; DelimiterArray[0] = NavigationMenu.PathSeparator; // Parse the value path of the Classical menu item // using the Split method. String[] nodeValues = item.ValuePath.Split(DelimiterArray); // Display the original and parsed values. Message.Text = "The original value path for the Classical menu item is <b>" + item.ValuePath + "</b>.<br/>"; Message.Text += "The individual values that make up the value " + "path are: <br/>"; foreach (String menuValue in nodeValues) { Message.Text += "- <b>" + menuValue + "</b><br/>"; } } </script> <html> <body> <form runat="server"> <h3>MenuItem ValuePath Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="1" staticsubmenuindent="10" orientation="Vertical" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> <hr/> <asp:label id="Message" 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に収録されているすべての辞書からMenuItem.ValuePath プロパティを検索する場合は、下記のリンクをクリックしてください。

- MenuItem.ValuePath プロパティのページへのリンク