Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  3 888

•  TDictionary Custom Sort  5 994

•  Fast Watermark Sources  5 782

•  3D Designer  8 597

•  Sik Screen Capture  6 123

•  Patch Maker  6 553

•  Айболит (remote control)  6 545

•  ListBox Drag & Drop  5 410

•  Доска для игры Реверси  95 270

•  Графические эффекты  6 759

•  Рисование по маске  5 923

•  Перетаскивание изображений  4 931

•  Canvas Drawing  5 309

•  Рисование Луны  5 034

•  Поворот изображения  4 575

•  Рисование стержней  3 248

•  Paint on Shape  2 490

•  Генератор кроссвордов  3 374

•  Головоломка Paletto  2 688

•  Теорема Монжа об окружностях  3 461

•  Пазл Numbrix  2 286

•  Заборы и коммивояжеры  2 969

•  Игра HIP  1 934

•  Игра Go (Го)  1 852

•  Симулятор лифта  2 186

•  Программа укладки плитки  1 917

•  Генератор лабиринта  2 356

•  Проверка числового ввода  2 046

•  HEX View  2 365

•  Физический маятник  1 998

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Сортировка TStringGrid



Оформил: DeeCo

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 
  // StringGrid1 nach der 1. Spalte sortieren 
  SortStringGrid(StringGrid1, 1);
 end;




Похожие по теме исходники

Сортировка методом Хоара

Сортировка списка

TStringGridCheker




Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте