掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
StringGridの並べ替えをするには? (ID:24558)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
StringGridを並び替えている関数です. 引数1:StringGrid名,引数2:優先する列 Procedure GridSort(Grid: TStringGrid; SortCol: Integer); var str_St1: TStringList; str_St2: TStringList; int_i: Integer; begin str_St1 := TStringList.Create; str_St1.Assign(Grid.Cols[SortCol]); for int_i := 1 To Grid.FixedRows Do str_St1.Delete(0); for int_i := 0 to str_St1.Count - 1 do str_St1.Strings[int_i] := str_St1.Strings[int_i] + #1 + Format('%.10d',[int_i]); for int_i := Grid.FixedRows to Grid.RowCount - 1 do begin str_St2 := TStringList.Create; str_St2.Assign(Grid.Rows[int_i]); str_St1.Objects[int_i - Grid.FixedRows] := str_St2; end; str_St1.Sort; for int_i := Grid.FixedRows to Grid.RowCount - 1 do begin Grid.Rows[int_i].Assign(TStringList(str_St1.Objects[int_i - Grid.FixedRows])); TStringList(str_St1.Objects[int_i - Grid.FixedRows]).Free; end; str_St1.Free; end; StringGridの中身を以下のように並び替えたいです.優先列を1列目にする. <並び替え前> [-2] [A] [ 2] [D] [-1] [B] [ 1] [C] <並び替え後> [-2] [A] [-1] [B] [ 1] [C] [ 2] [D] 宜しくお願いします.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.