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

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

TreeNodeBinding.FormatString プロパティ

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

TreeNodeBinding オブジェクト適用されるノードテキスト表示形式指定する文字列取得または設定します

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

<LocalizableAttribute(True)> _
Public Property FormatString As
 String
Dim instance As TreeNodeBinding
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)

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

解説解説

FormatString プロパティ使用してノードテキストカスタム書式提供しますデータ書式指定文字列は、{ A : Bxx } の書式で、コロン区切られ2 つ部分から構成されます。たとえば、書式指定文字列 {0:F2}使用すると、2 固定小数点数表示されます。

メモメモ

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

コロンの前の値 (一般的な例での A) は 0 から始まるパラメータリストパラメータ インデックス指定します

メモメモ

ノードには 1 つ値しかないため、この値は必ず 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>

前の例に対応したサンプル XML データ次のコード例示します

<Book Title="Book Title">
    <Chapter Heading="Chapter 1">
        <Section Heading="Section 1">
        </Section>
        <Section Heading="Section 2">
        </Section>
    </Chapter>
    <Chapter Heading="Chapter 2">
        <Section Heading="Section 1">
        </Section>
    </Chapter>
    <Appendix Heading="Appendix A">
    </Appendix>
</Book>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TreeNodeBinding クラス
TreeNodeBinding メンバ
System.Web.UI.WebControls 名前空間
TreeView
TreeNode クラス
DataBindings
その他の技術情報
書式設定概要


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS