Autor Beitrag
moontear
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Do 03.05.07 11:32 
Hello, people! Please, help me! How am I writeing QuickSort algotiram for ListView?


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, Mask, Menus, ComCtrls;
   
type

  TPersonInfo = record
    Number: Integer;
    Name: String;
    Age: Integer;
  end;
  PPersonInfo = ^TpersonInfo;

  TForm1 = class(TForm)
    Add: BitAdd;
    Label4: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    ListV: TListView;
    EdNumber: TEdit;
    EdName: TEdit;
    EdAge: TEdit;
    MainMenu1: TMainMenu;
    FL: TMenuItem;
    Save: TMenuItem;
    Edit: TMenuItem;
    DEL: TMenuItem;
    Sort: TMenuItem;
    

    procedure ListVDblClick(Sender: TObject);
    procedure AddClick(Sender: TObject);
    procedure EditClick(Sender: TObject);
    procedure DELClick(Sender: TObject);
    procedure SaveClick(Sender: TObject);
 
    private

        { Private declarations }
  public


    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.AddClick(Sender: TObject);
 var ListItem:TListItem;
     TempPersonInfo: PPersonInfo;
 begin
   TempPersonInfo := New(PPersonInfo);      
   TempPersonInfo.Age := StrToInt(EdAge.Text);           
   TempPersonInfo.Name := EdName.Text;                          
  TempPersonInfo.Number := StrToInt(EdNumber.Text);      
  with ListV do
    begin
     ListItem := Items.Add;
     ListItem.Data := Pointer(TempPersonInfo);
     ListItem.Caption := IntToStr(TempPersonInfo.Number) 
     ListItem.SubItems.Add(TempPersonInfo.Name );
     ListItem.SubItems.Add(IntToStr(TempPersonInfo.Age)
     Selected:=ListItem;
    end
 end;
procedure TForm1.ListVDblClick(Sender: TObject);
 var ListItem:TListItem;
  begin
   with ListV do
     begin
      ListItem :=  Items[Selected.Index];
      Edit1.Text := ListItem.Caption;
      Edit2.Text := ListItem.SubItems[0];
      Edit3.Text := ListItem.SubItems[1];
     end
  end;
procedure TForm1.EditClick(Sender: TObject);
  begin
   if ListV.SelCount<1 then exit;
    with ListV.Selected 
      begin
       PPersonInfo(Data).Age := StrToInt(EdAge.Text);         
       PPersonInfo(Data).Name := EdName.Text;
       PPersonInfo(Data).Number := StrToInt(EdNumber.Text);
       Caption :=EdNumber.Text;
       SubItems[0] :=EdName.Text;
       SubItems[1] :=EdAge.Text;
      end
  end;
procedure TForm1.DELClick(Sender: TObject);
 var DelInt:Integer;
  begin
   if ListV.SelCount<1 then exit;
      DelInt:=ListV.Selected.Index;
      ListV.Items.Delete(DelInt);
   if DelInt>ListV.Items.Count-1 then DelInt:=ListV.Items.Count-1;
      ListV.Selected :=ListV.Items[DelInt];
  end;
procedure TForm1.SaveClick(Sender: TObject);
 var f: textfile;
     ListItem: TListitem;
     i: Integer;
  begin
  assignfile(f, 'DataList.txt');
  rewrite (f);
   with ListV do for i :=0 to Items.Count-1 do
     begin
       ListItem := Items[i];
         with ListItem do writeln(f, Caption,';', SubItems[0],';', SubItems[1]);
     end;
   closefile(f);
 end;
end.



Moderiert von user profile iconChristian S.: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Do 03.05.2007 um 12:39
Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt


Zuletzt bearbeitet von moontear am Fr 04.05.07 07:40, insgesamt 1-mal bearbeitet
FiceGoesDelphi
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Do 03.05.07 11:41 
Hello and welcome to our community,

first u have to write another headline for ur thread!
So we can see whats ur thread about like "Quicksort Problem" or so.
second u have to put ur DelphiCode in DelphiTags like:

[delphi]

here ur code

[/delphi]

then, i think so, we can help u easier


P.S. Sry for my bad english :oops:
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.05.07 11:42 
Hello!

Please choose another title for your topic. "Please, Help me!" doesn't tell the reader what this topic is about. In order to change the title, just click user defined image or user defined image in your first posting.

Thank you! :-)

Bye
Christian

@FiceGoesDelphi: Please leave such hints to the team, just use the virtual contact (virtueller Ansprechpartner) to inform us.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 03.05.07 11:43 

_________________
Markus Kinzler.