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

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

•  TDictionary Custom Sort  5 655

•  Fast Watermark Sources  5 421

•  3D Designer  7 883

•  Sik Screen Capture  5 720

•  Patch Maker  6 211

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

•  ListBox Drag & Drop  5 089

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

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

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

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

•  Canvas Drawing  4 983

•  Рисование Луны  4 714

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

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

•  Paint on Shape  2 232

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

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

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

•  Пазл Numbrix  2 105

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

•  Игра HIP  1 726

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

•  Симулятор лифта  1 965

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

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

•  Проверка числового ввода  1 818

•  HEX View  2 092

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

 
скрыть


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

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