次の方法で共有


DataView.Sort プロパティ

DataView の並べ替え列と並べ替え順序を取得または設定します。

Public Property Sort As String
[C#]
public string Sort {get; set;}
[C++]
public: __property String* get_Sort();public: __property void set_Sort(String*);
[JScript]
public function get Sort() : String;public function set Sort(String);

プロパティ値

列名の後に "ASC" (昇順) または "DESC" (降順) を付けた文字列。既定では、列は昇順に並べ替えられます。複数の列をコンマで区切って指定できます。

解説

詳細については、「 DataView の作成と使用 」を参照してください。

使用例

[Visual Basic, C#, C++] 2 つの列によってテーブルを並べ替えるよう DataView に指示する例を次に示します。

 
Private Sub SortByTwoColumns()
   ' Get the DefaultViewManager of a DataTable.
   Dim myDataView As DataView
   myDataView = DataTable1.DefaultView
   ' By default, the first column sorted ascending.
   myDataView.Sort = "State, ZipCode DESC"
End Sub

[C#] 
private void SortByTwoColumns()
{
   // Get the DefaultViewManager of a DataTable.
   DataView myDataView = DataTable1.DefaultView;
   // By default, the first column sorted ascending.
   myDataView.Sort = "State, ZipCode DESC";
}

[C++] 
private:
 void SortByTwoColumns()
 {
    // Get the DefaultViewManager of a DataTable.
    DataView* myDataView = DataTable1->DefaultView;
    // By default, the first column sorted ascending.
    myDataView->Sort = S"State, ZipCode DESC";
 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

DataView クラス | DataView メンバ | System.Data 名前空間 | RowFilter | Expression