unit Source;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CheckLst;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
procedure CheckListBoxDblClick(Sender: TObject);
procedure CheckListBoxExit(Sender: TObject);
private
Edit1: TEdit;
CheckListBox : TCheckListBox;
public
{ Public-Deklarationen }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
Var DrawRect: TRect;
begin CheckListBox:=TCheckListBox.Create(Form1);
CheckListBox.Parent:=Form1;
CheckListBox.Font.Size:=10;
CheckListBox.OnDblClick:=CheckListBoxDblClick;
CheckListBox.OnExit:=CheckListBoxExit;
CheckListBox.Items.Add('
Zeile 1');
CheckListBox.Items.Add('
Zeile 2');
CheckListBox.Items.Add('
Zeile 3');
{== Editfeld als Kind von CheckListBox ableiten =======}
Edit1:=TEdit.Create(Form1);
Edit1.Parent:=CheckListBox;
{== Ermitteln der Edit.Höhe über Größe der CheckListbox ==}
DrawRect:=CheckListBox.ItemRect(0);
Edit1.Height:=DrawRect.Bottom-DrawRect.Top+1;
//Zeile: *1
Edit1.Visible:=false;
end;
procedure TForm1.CheckListBoxDblClick(Sender: TObject);
Var DrawRect: TRect;
begin DrawRect:=CheckListBox.ItemRect(CheckListBox.ItemIndex);
Edit1.Text:=CheckListBox.Items.Strings[CheckListBox.ItemIndex];
Edit1.Top:=DrawRect.Top;
Edit1.Height:=DrawRect.Bottom-DrawRect.Top+2;
//Zeile: *2
Edit1.Visible:=true;
end;
procedure TForm1.CheckListBoxExit(Sender: TObject);
begin Edit1.Visible:=false;
end;
end.