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

•  DeLiKaTeS Tetris (Тетрис)  4 294

•  TDictionary Custom Sort  6 340

•  Fast Watermark Sources  6 128

•  3D Designer  9 059

•  Sik Screen Capture  6 450

•  Patch Maker  6 866

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

•  ListBox Drag & Drop  5 727

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

•  Графические эффекты  7 069

•  Рисование по маске  6 369

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

•  Canvas Drawing  5 613

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

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

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

•  Paint on Shape  2 708

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

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

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

•  Пазл Numbrix  2 417

•  Заборы и коммивояжеры  3 098

•  Игра HIP  2 058

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

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

•  Программа укладки плитки  2 046

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

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

•  HEX View  2 517

•  Физический маятник  2 133

 
скрыть

  Форум  

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

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