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

Dim instance As TreeNodeBinding 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)
TreeNodeBinding オブジェクトが適用されるノードのテキストの表示形式を指定する書式指定文字列。既定値は空の文字列 ("") です。FormatString プロパティが設定されていないことを示します。

FormatString プロパティを使用して、ノードのテキストのカスタム書式を提供します。データ書式指定文字列は、{ A : Bxx } の書式で、コロンで区切られた 2 つの部分から構成されます。たとえば、書式指定文字列 {0:F2} を使用すると、2 桁の固定小数点数で表示されます。
![]() |
---|
文字列の全体はリテラル文字列ではなく、書式指定文字列であることを示すために、中かっこ ({}) で囲む必要があります。かっこの外側のテキストはリテラル テキストとして表示されます。 |
コロンの前の値 (一般的な例での A) は 0 から始まるパラメータのリストのパラメータ インデックスを指定します。
![]() |
---|
コロンの後の文字 (一般的な例での B) は値の表示形式を指定します。共通の書式を次の表に示します。
書式指定文字の後の値 (一般的な例での xx) は、表示する有効桁数または小数点を指定します。
書式指定文字列の詳細については、「書式設定の概要」を参照してください。
FormatString プロパティを設定している場合、デザイナ ツールを使用して、その値を自動的にリソース ファイルに保存できます。詳細については、LocalizableAttribute のトピックおよび「ASP.NET のグローバリゼーションおよびローカリゼーション」を参照してください。

このセクションには、2 つのコード例が含まれています。FormatString プロパティを使用して、ルート ノードに表示されるテキストのカスタムの表示形式を指定する方法を最初のコード例に示します。最初のコード例に対応したサンプル XML データを 2 番目のコード例に示します。
FormatString プロパティを使用して、ルート ノードに表示されるテキストのカスタムの表示形式を指定する方法を次のコード例に示します。この例を正常に動作させるには、このコード例の後に示すサンプル XML データを、Book.xml という名前のファイルにコピーする必要があります。
<%@ Page Language="VB" %> <html> <body> <form runat="server"> <h3>TreeNodeBinding FormatString Example</h3> <!-- Use the FormatString property to apply --> <!-- a custom format string to the root node. --> <!-- The placeholder ({0}) is automatically --> <!-- replaced with the value of the field --> <!-- specified in the TextField property. --> <asp:TreeView id="BookTreeView" DataSourceID="BookXmlDataSource" runat="server"> <DataBindings> <asp:TreeNodeBinding DataMember="Book" Depth="0" TextField="Title" FormatString="Best Seller: {0}"/> <asp:TreeNodeBinding DataMember="Chapter" Depth="1" TextField="Heading"/> <asp:TreeNodeBinding DataMember="Appendix" Depth="1" TextField="Heading"/> </DataBindings> </asp:TreeView> <asp:XmlDataSource id="BookXmlDataSource" DataFile="Book.xml" runat="server"> </asp:XmlDataSource> </form> </body> </html>
<%@ Page Language="C#" %> <html> <body> <form runat="server"> <h3>TreeNodeBinding FormatString Example</h3> <!-- Use the FormatString property to apply --> <!-- a custom format string to the root node. --> <!-- The placeholder ({0}) is automatically --> <!-- replaced with the value of the field --> <!-- specified in the TextField property. --> <asp:TreeView id="BookTreeView" DataSourceID="BookXmlDataSource" runat="server"> <DataBindings> <asp:TreeNodeBinding DataMember="Book" Depth="0" TextField="Title" FormatString="Best Seller: {0}"/> <asp:TreeNodeBinding DataMember="Chapter" Depth="1" TextField="Heading"/> <asp:TreeNodeBinding DataMember="Appendix" Depth="1" TextField="Heading"/> </DataBindings> </asp:TreeView> <asp:XmlDataSource id="BookXmlDataSource" DataFile="Book.xml" runat="server"> </asp:XmlDataSource> </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に収録されているすべての辞書からTreeNodeBinding.FormatString プロパティを検索する場合は、下記のリンクをクリックしてください。

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