Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi dynamische erzeugte buttons und onclick procedure (https://www.delphipraxis.net/1720-dynamische-erzeugte-buttons-und-onclick-procedure.html)

maosmurf 11. Mär 2004 22:48

Re: dynamische erzeugte buttons und onclick procedure
 
DANKE EUCH!!!

ich habe ca 2h nach der lösung gesucht, die ihr mir bietet!

mein prob war wie folgt: ich habe ein array von scrollbars und ein array von edits (und davon jeweils ziemlich viele...)
aufgabe: bei verschieben von scrbar[i] soll die position in edit[i] ausgeschrieben werden.
ich könnte ca 100 onclicks erstellen, aber das wäre etwas SEHR mühsam...

erstellt hab ichs so:

Delphi-Quellcode:
 for j:=2 to 4 do
 begin
   aktuellebox:=j;
   gr[j]:=TGroupBox.Create(Form1);
   with gr[j] do
   begin
   Parent := Panel;
   Top   := 0;
   Left  := (j-2)*(Panel.Width div 3);
   Width := Panel.Width div 3;
   Height := Panel.Height;
   end;

   txt[j]:=TEdit.Create(Form1);
   with txt[j] do
   begin
   Parent := gr[j];
   Left  := 10;
   Height := 20;
   Top   := 20;
   Width := gr[j].Width-2*txt[j].Left;
   Text  := inttostr(j);
   end;

   scr[j]:=TScrollbar.Create(Form1);
   with scr[j] do
   begin
   Parent := gr[j];
   Left  := txt[j].Left;
   Height := txt[j].height;
   Top   := 50;
   Width := gr[j].Width-2*txt[j].Left;
   Min   := 0;
   Max   := 1000;
   SmallChange:= 1;
   LargeChange:= 50;
   scr[j].OnChange:=scroll;
   end;
 end;
und dann dank euch

Delphi-Quellcode:
procedure TForm1.scroll(Sender: TObject);
var i: integer;
begin
for i:= 2 to 4 do
if sender = scr[i] then txt[i].Text:=inttostr(scr[i].Position);
end;
is eigentlich deppeneinfach, aber ihr wisst ja wie das so is... :wall:

auf jeden Fall :love: DANKE :cheers: ihr seid die EINZIGEN im internet die mir das beantworten konnten!

lg maosmurf


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:24 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz