PowerTools SPREAD for Windows Forms 8.0J
テーブルの並べ替え

ユーザーがテーブルのデータを並べ替えるには、見出し行のドロップダウンアイコンをクリックして並べ替えに関するオプションを選択します。

また、コーディングにてデータを並べ替えることもできます。

設定方法

コードでテーブルのデータを並べ替えるには、TableViewクラスのSort メソッドを使用します。

サンプルコード

次のサンプルコードは、テーブルのデータを並べ替えます。

C#
コードのコピー
FarPoint.Win.Spread.TableStyle tstyle = fpSpread1.CreateTableStyle("Style1", FarPoint.Win.Spread.TableStyle.TableStyleLight2);
fpSpread1.Sheets[0].Cells[1, 1].Text = "名前";
fpSpread1.Sheets[0].Cells[1, 2].Text = "値";
fpSpread1.Sheets[0].Cells[2, 1].Text = "青木";
fpSpread1.Sheets[0].Cells[2, 2].Value = 50;
fpSpread1.Sheets[0].Cells[3, 1].Text = "明美";
fpSpread1.Sheets[0].Cells[3, 2].Value = 10;
fpSpread1.Sheets[0].Cells[4, 1].Text = "春樹";
fpSpread1.Sheets[0].Cells[4, 2].Value = 78;
fpSpread1.TableStyleCollection.Add(tstyle);
FarPoint.Win.Spread.TableView table = fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2, "Style1");      
FarPoint.Win.Spread.ComplexSortInfo[] sort = new FarPoint.Win.Spread.ComplexSortInfo[1];
sort[0] = new FarPoint.Win.Spread.ComplexSortInfo(1, true);
table.Sort(sort);
Visual Basic
コードのコピー
Dim tstyle As FarPoint.Win.Spread.TableStyle
tstyle = FpSpread1.CreateTableStyle("Style1", FarPoint.Win.Spread.TableStyle.TableStyleLight2)
FpSpread1.Sheets(0).Cells(1, 1).Text = "名前"
FpSpread1.Sheets(0).Cells(1, 2).Text = "値"
FpSpread1.Sheets(0).Cells(2, 1).Text = "青木"
FpSpread1.Sheets(0).Cells(2, 2).Value = 50
FpSpread1.Sheets(0).Cells(3, 1).Text = "明美"
FpSpread1.Sheets(0).Cells(3, 2).Value = 10
FpSpread1.Sheets(0).Cells(4, 1).Text = "春樹"
FpSpread1.Sheets(0).Cells(4, 2).Value = 78
FpSpread1.TableStyleCollection.Add(tstyle)
Dim table As FarPoint.Win.Spread.TableView =  FpSpread1.Sheets(0).AddTable("table", 1, 1, 5, 2, "Style1")
Dim sort As FarPoint.Win.Spread.ComplexSortInfo() = New FarPoint.Win.Spread.ComplexSortInfo(0) {}
sort(0) = New FarPoint.Win.Spread.ComplexSortInfo(1, True)
table.Sort(sort)
関連トピック

 

 


© 2004-2015, GrapeCity inc. All rights reserved.