Показать сообщение отдельно
  #1  
Старый 26.04.2010, 22:21
xpom xpom вне форума
Прохожий
 
Регистрация: 26.04.2010
Сообщения: 3
Репутация: 10
По умолчанию Столкнулся с проблемой

Столкнулся с проблемой, задача написать грубо говоря телефонную книгу...
на форме находятся: 9 Edit'ов, после занесения данных в них, и после нажатия кнопки добавить, данные переносятся в ListBox, как из ListBox'а вернуть данные в Edit'ы???
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    ListBox1: TListBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit7: TEdit;
    Edit8: TEdit;
    Label7: TLabel;
    Label9: TLabel;
    Button4: TButton;
    Button5: TButton;
    SaveDialog1: TSaveDialog;
    OpenDialog1: TOpenDialog;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Label8: TLabel;
    Edit9: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
  Edit1.Text:='';
  Edit2.Text:='';
  Edit3.Text:='';
  Edit4.Text:='';
  Edit5.Text:='';
  Edit6.Text:='';
  Edit7.Text:='';
  Edit8.Text:='';
  Edit9.Text:='';
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
       ListBox1.Items.Add(Edit1.Text+', '+Edit2.Text+' '+Edit3.Text);
end;


procedure TForm1.Button4Click(Sender: TObject);
begin
   ListBox1.Items.Clear;
end;

procedure TForm1.ListBox1Click(Sender: TObject);


begin
    Edit1.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit2.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit3.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit4.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit5.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit6.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit7.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit8.Text:=ListBox1.Items[ListBox1.ItemIndex];
    Edit9.Text:=ListBox1.Items[ListBox1.ItemIndex];
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
   ListBox1.Items.Delete(1);
end;




procedure TForm1.Button6Click(Sender: TObject);
begin


 if OpenDialog1.Execute then

            ListBox1.Items.LoadFromFile(OpenDialog1.FileName);
 OpenDialog1.Filter:='.txt; .ini; .tmp';
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
SaveDialog1.Execute;

            ListBox1.Items.SaveToFile(SaveDialog1.FileName);
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
 with SaveDialog1 do
      if Execute then
        begin
           ListBox1.Items.SaveToFile('FileName');
           OpenDialog1.FileName:=FileName; 
        end;
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
 Close;
end;

end.
Ответить с цитированием