
20.05.2014, 13:52
|
 |
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMyObject = class(TObject)
i: Integer;
constructor Create(i: Integer);
end;
TForm1 = class(TForm)
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TMyObject }
constructor TMyObject.Create(i: Integer);
begin
Self.i:=i;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Items.AddObject('1', TMyObject.Create(1));
ListBox1.Items.AddObject('22', TMyObject.Create(22));
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
ShowMessage(IntToStr(TMyObject(ListBox1.Items.Objects[ListBox1.ItemIndex]).i));
end;
end.
__________________
Пишу программы за еду.
__________________
|