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

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

MenuItemBinding.FormatString プロパティ

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

MenuItemBinding オブジェクト適用されるメニュー項目のテキスト表示形式指定する文字列取得または設定します

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

<LocalizableAttribute(True)> _
Public Property FormatString As
 String
Dim instance As MenuItemBinding
Dim value As String

value = instance.FormatString

instance.FormatString = value
[LocalizableAttribute(true)] 
public string FormatString { get;
 set; }
[LocalizableAttribute(true)] 
public:
property String^ FormatString {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_FormatString ()

/** @property */
public void set_FormatString (String value)
public function get FormatString
 () : String

public function set FormatString
 (value : String)

プロパティ
MenuItemBinding適用されるメニュー項目のテキスト表示形式指定する書式指定文字列既定値空の文字列 ("") です。このプロパティ設定されていないことを示します

解説解説

FormatString プロパティ使用してメニュー項目のテキストカスタム書式提供します書式指定文字列には、リテラル文字列とプレースホルダのいずれか、または両方指定できますリテラル文字列そのまま表示されますが、プレースホルダはメニュー項目のテキストバインドされている値で置き換えられます。

プレースホルダは、{A:Bxx} の書式で、コロン区切られ2 つ部分分割されます。たとえば、{0:F2} を使用すると、2 固定小数点数表示されます。

メモメモ

プレースホルダ文字列は、リテラル文字列ではなく、プレースホルダであることを示すために、中かっこ ({}) で囲む必要があります。かっこの外側テキストリテラル テキストとして表示されます。

標準書式指定文字列構文に従ってコロンの前の値 (一般的な例での A) には 0 から始まるパラメータリストパラメータ インデックス指定します。各メニュー項目には 1 つ値し表示できないため、パラメータ インデックスには 0 のみが設定できます

コロンの後の文字 (一般的な例での B) は値の表形式指定します。共通の書式次の表に示します

書式指定文字の後の値 (一般的な例での xx) は、表示する有効桁数または小数点指定します

書式指定文字列詳細については、「書式設定概要」を参照してください

このプロパティ設定している場合デザイナ ツール使用して、その値を自動的にリソース ファイル保存できます詳細については、LocalizableAttribute、ASP.NETグローバリゼーションおよびローカリゼーション の各トピック参照してください

使用例使用例

FormatString プロパティ使用してMenu コントロールメニュー項目に表示されるテキスト書式設定する方法次のコード例示します。この例を正常に動作させるには、以下のサンプル XML データを、Menu.xml という名前のファイルコピーする必要があります

<%@ page language="VB" %>

<html>
  <body>
    <form runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode"
 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode"
 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </form>
  </body>
</html>

<%@ page language="C#" %>

<html>
  <body>
    <form runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode" 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode" 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </form>
  </body>
</html>

前の例のサンプル サイト マップ データ次のコード示します

<MapHomeNode ImageUrl="~\Images\Home.gif"

Title="Home"

Description="Root Page"

ToolTip="Home Page">

<MapNode ImageUrl="~\Images\Music.gif"

Title="Music"

Description="Music Category"

ToolTip="Music Page">

<MapNode ImageUrl="~\Images\Classical.gif"

Title="Classical"

Description="Classical Section"

ToolTip="Classical Page"/>

<MapNode ImageUrl="~\Images\Rock.gif"

Title="Rock"

Description="Rock Section"

ToolTip="Rock Page"/>

<MapNode ImageUrl="~\Images\Jazz.gif"

Title="Jazz"

Description="Jazz Section"

ToolTip="Jazz Page"/>

</MapNode>

<MapNode ImageUrl="~\Images\Movies.gif"

Title="Movies"

Description="Movies Category"

ToolTip="Movies Page">

<MapNode ImageUrl="~\Images\Action.gif"

Title="Action"

Description="Action Section"

ToolTip="Action Page"/>

<MapNode ImageUrl="~\Images\Drama.gif"

Title="Drama"

Description="Drama Section"

ToolTip="Drama Page"/>

<MapNode ImageUrl="~\Images\Musical.gif"

Title="Musical"

Description="Musical Section"

ToolTip="Musical Page"/>

</MapNode>

</MapHomeNode>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuItemBinding クラス
MenuItemBinding メンバ
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemBindingCollection
Menu.DataBindings プロパティ
Text
TextField
その他の技術情報
書式設定概要


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

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

辞書ショートカット

すべての辞書の索引

「MenuItemBinding.FormatString プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS