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

•  Animation Loaders  1 057

•  DeLiKaTeS Tetris (Тетрис)  5 990

•  TDictionary Custom Sort  7 927

•  Fast Watermark Sources  7 584

•  3D Designer  10 823

•  Sik Screen Capture  8 165

•  Patch Maker  8 351

•  Айболит (remote control)  8 402

•  ListBox Drag & Drop  7 261

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

•  Графические эффекты  8 457

•  Рисование по маске  7 822

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

•  Canvas Drawing  6 801

•  Рисование Луны  6 740

•  Поворот изображения  5 838

•  Рисование стержней  4 784

•  Paint on Shape  3 480

•  Генератор кроссвордов  4 500

•  Головоломка Paletto  3 622

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

•  Пазл Numbrix  2 860

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

•  Игра HIP  2 582

•  Игра Go (Го)  2 597

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

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

•  Генератор лабиринта  3 155

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

•  HEX View  3 048

 
скрыть

  Форум  

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-2026 "Delphi Sources" by «SiteAnalyzer». Delphi World FAQ

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