MenuItem.ValuePath プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MenuItem.ValuePath プロパティの意味・解説 

MenuItem.ValuePath プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

ルート メニュー項目から現在のメニュー項目までのパス取得します

名前空間: System.Web.UI.WebControls
アセンブリ: 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>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuItem クラス
MenuItem メンバ
System.Web.UI.WebControls 名前空間
Menu.PathSeparator プロパティ
FindItem


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

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

辞書ショートカット

すべての辞書の索引

MenuItem.ValuePath プロパティのお隣キーワード
検索ランキング

   

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



MenuItem.ValuePath プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS