Arsip: Sorting pada Stringgrid????

 
user image
more 15 years ago

akudana

Bagaimana caranya untuk sorting pada stringgrid?? contoh programnya.... mohon bantuannya...
user image
more 15 years ago

elva_ivana

Code ini diambil dari salah satu tutorial ... monggo di kembangkan lagi sesuai keinginan

procedure SortStringGrid(var GenStrGrid: TStringGrid; ThatCol: integer);
const
 // Define the Separator
  TheSeparator = '@';
var
  CountItem, I, J, K, ThePosition: integer;
  MyList: TStringList;
  MyString, TempString: string;
begin
 // Give the number of rows in the StringGrid
  CountItem     := GenStrGrid.RowCount;
 //Create the List
  MyList        := TStringList.Create;
  MyList.Sorted := False;
  try
    begin
      for I := 1 to (CountItem - 1) do
        MyList.Add(GenStrGrid.Rows[I].Strings[ThatCol] + TheSeparator +
          GenStrGrid.Rows[I].Text);
   //Sort the List
      Mylist.Sort;
      for K := 1 to Mylist.Count do
      begin
     //Take the String of the line (K – 1)
        MyString    := MyList.Strings[(K - 1)];
     //Find the position of the Separator in the String
        ThePosition := Pos(TheSeparator, MyString);
        TempString  := '';
     {Eliminate the Text of the column on which we have sorted the StringGrid}
        TempString  := Copy(MyString, (ThePosition + 1), Length(MyString));
        MyList.Strings[(K - 1)] := '';
        MyList.Strings[(K - 1)] := TempString;
      end;
   // Refill the StringGrid
      for J := 1 to (CountItem - 1) do
        GenStrGrid.Rows[J].Text := MyList.Strings[(J - 1)];
    end;
  finally
  //Free the List
    MyList.Free;
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  // Sort the StringGrid1 on the second Column
  SortStringGrid(StringGrid1, 1);
end;
user image
more 15 years ago

akudana

rumit mas yang simpel ada nggak........
user image
more 15 years ago

elva_ivana

walah... pengen instant to' .... pake ADVStringgrid dari TMS atau QuantumGrid dari DevEx ....
user image
more 15 years ago

DelphiExpert

@akudana: rumit mas yang simpel ada nggak........
haha seperti biasa... yang simple bayar programmer aja wakaka... simple tinggal pencet tombol kombinasi key-dongle :mrgreen:
user image
more 15 years ago

elva_ivana

@DelphiExpert:
@akudana: rumit mas yang simpel ada nggak........
haha seperti biasa... yang simple bayar programmer aja wakaka... simple tinggal pencet tombol kombinasi key-dongle :mrgreen:
wakkakakak.. serahin aja ama mbah @DE, pasti lebih simple and cepet ... wakakakak trus jangan lupa bilang Terima kasih Mamah,kakak,bapak semua
user image
more 15 years ago

mantihaa

[OOT] @elva_ivana jangan lupa nya kurang ... bayar nya kapan ? :mrgreen:
user image
more 15 years ago

akudana

ok...............trims buat semua
more ...
  • Pages:
  • 1
Share to

AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com