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

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

BindingSource.Sort プロパティ

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

並べ替え使用する列名と、データ ソースで行を表示するときの並べ替え順序取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

Sort プロパティは、行の並べ替え使用する列名と並べ替え順序指定する大文字と小文字区別される文字列です。既定では、列は昇順並べ替えられます。複数の列を指定する場合は、"State, ZipCode DESC" のようにコンマ区切ります

基底リスト並べ替えサポートするには、IBindingList インターフェイスまたは IBindingListView インターフェイス実装している必要があります。この機能サポートされているかどうかは、SupportsSorting プロパティ使用して問い合わせることができます。SupportsAdvancedSorting プロパティtrue場合は、複数列の並べ替えサポートされています。

Sort プロパティ設定すると、内部リストが型に応じて次のように変更されます。

内部リスト並べ替えプロパティ変更されるのは、並べ替え文字列null 参照 (Visual Basic では Nothing) でない場合のみです。このプロパティget アクセサは、内部リスト並べ替え値を取得せず、代わりに set アクセサの値を返しますSort プロパティの値は、データ ソース変更されても保持されます。

使用例使用例

Filter プロパティSort プロパティコード例次に示します。この例を実行するには、BindingSource1 という名前の BindingSource と、dataGridView1 という名前の DataGridView を含むフォームコード貼り付けます。次にフォーム読み込みイベント処理し読み込みイベント処理メソッドInitializeSortedFilteredBindingSource呼び出します。Visual Basic使用する場合、System.Data.dll への参照追加する必要があります

Private Sub InitializeSortedFilteredBindingSource()

    ' Create the connection string, data adapter and data table.
    Dim connectionString As New
 SqlConnection("Initial Catalog=Northwind;" &
 _
        "Data Source=localhost;Integrated Security=SSPI;")
    Dim customersTableAdapter As New
 SqlDataAdapter("Select * from Customers", _
        connectionString)
    Dim customerTable As New
 DataTable()

    ' Fill the the adapter with the contents of the customer table.
    customersTableAdapter.Fill(customerTable)

    ' Set data source for BindingSource1.
    BindingSource1.DataSource = customerTable

    ' Filter the items to show contacts who are owners.
    BindingSource1.Filter = "ContactTitle='Owner'"
    ' Sort the items on the company name in descending order.
    BindingSource1.Sort = "Country DESC, Address ASC"

    ' Set the data source for dataGridView1 to BindingSource1.
    dataGridView1.DataSource = BindingSource1

   
End Sub

private void InitializeSortedFilteredBindingSource()
{
    // Create the connection string, data adapter and data table.
    SqlConnection connectionString =
         new SqlConnection("Initial Catalog=Northwind;"
 +
         "Data Source=localhost;Integrated Security=SSPI;");
    SqlDataAdapter customersTableAdapter =
        new SqlDataAdapter("Select * from Customers",
 connectionString);
    DataTable customerTable = new DataTable();

    // Fill the the adapter with the contents of the customer table.
    customersTableAdapter.Fill(customerTable);

    // Set data source for BindingSource1.
    BindingSource1.DataSource = customerTable;

    // Filter the items to show contacts who are owners.
    BindingSource1.Filter = "ContactTitle='Owner'";

    // Sort the items on the company name in descending order.
    BindingSource1.Sort = "Country DESC, Address ASC";

    // Set the data source for dataGridView1 to BindingSource1.
    dataGridView1.DataSource = BindingSource1;

}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingSource クラス
BindingSource メンバ
System.Windows.Forms 名前空間
BindingSource.Filter プロパティ
RemoveSort


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS