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

Dim instance As MenuItemBinding Dim value As String value = instance.FormatString instance.FormatString = value
[LocalizableAttribute(true)] public: property String^ FormatString { String^ get (); void set (String^ value); }
/** @property */ public String get_FormatString () /** @property */ public void set_FormatString (String value)
MenuItemBinding が適用されるメニュー項目のテキストの表示形式を指定する書式指定文字列。既定値は空の文字列 ("") です。このプロパティが設定されていないことを示します。

FormatString プロパティを使用して、メニュー項目のテキストのカスタム書式を提供します。書式指定文字列には、リテラル文字列とプレースホルダのいずれか、または両方を指定できます。リテラル文字列はそのまま表示されますが、プレースホルダはメニュー項目のテキストにバインドされている値で置き換えられます。
プレースホルダは、{A:Bxx} の書式で、コロンで区切られた 2 つの部分に分割されます。たとえば、{0:F2} を使用すると、2 桁の固定小数点数で表示されます。
![]() |
---|
プレースホルダ文字列は、リテラル文字列ではなく、プレースホルダであることを示すために、中かっこ ({}) で囲む必要があります。かっこの外側のテキストはリテラル テキストとして表示されます。 |
標準の書式指定文字列構文に従って、コロンの前の値 (一般的な例での A) には 0 から始まるパラメータのリストのパラメータ インデックスを指定します。各メニュー項目には 1 つの値しか表示できないため、パラメータ インデックスには 0 のみが設定できます。
コロンの後の文字 (一般的な例での B) は値の表示形式を指定します。共通の書式を次の表に示します。
C | |
D | |
E | |
F | |
G | |
N | |
X |
書式指定文字の後の値 (一般的な例での 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"
<MapNode ImageUrl="~\Images\Music.gif"
<MapNode ImageUrl="~\Images\Classical.gif"
Description="Classical Section"
<MapNode ImageUrl="~\Images\Rock.gif"
<MapNode ImageUrl="~\Images\Jazz.gif"
</MapNode>
<MapNode ImageUrl="~\Images\Movies.gif"
<MapNode ImageUrl="~\Images\Action.gif"
<MapNode ImageUrl="~\Images\Drama.gif"
<MapNode ImageUrl="~\Images\Musical.gif"
</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に収録されているすべての辞書からMenuItemBinding.FormatString プロパティを検索する場合は、下記のリンクをクリックしてください。

- MenuItemBinding.FormatString プロパティのページへのリンク