Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Problem Treeview.Add / TreeviewAddition... (https://www.delphipraxis.net/77233-problem-treeview-add-treeviewaddition.html)

DeluxXx 16. Sep 2006 18:05


Problem Treeview.Add / TreeviewAddition...
 
Also ich bin grad irgendwie festgefahrem mit einem Treeview
Delphi-Quellcode:

procedure TForm1.FormShow(Sender: TObject);
begin
//Form1.Height := 167 ;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
I : Integer ;
begin
//Ändere Die Größere und setze die Listbox aus sichtbar
//Form1.Height := 321 ;
//Listbox1.Visible := True ;
if (Edit1.Text <> '') and (Edit2.Text <> '') and (Edit3.Text <>'') then
begin
nNode := Treeview1.Items.AddFirst(Treeview1.Selected, Edit1.Text) ;
 // BroadCast(Edit1.Text) ;
end
  else
  begin
  Showmessage('Bitte füllen sie Startort,Zielort und Startzeit aus!') ;
  end;
end;

procedure TForm1.TreeView1Addition(Sender: TObject; Node: TTreeNode);
begin
if Hops < 25 then
  begin
    Hops := Hops +1 ;
    Broadcast(Node.Text) ;
  end;
end;

procedure TForm1.Broadcast(Trainstation : string) ;
var
TrainstationDest,TrainstationDestination,FinalDestination,Line,Info : string ;
Destinations : TStringlist ;
I : Integer ;

begin
  //Look for all Destinations the Trainstation is going to in the DB
   with AdsTable1 do
  begin
    if not Active then
    Open ;
    Locate('Bahnhof',Trainstation,[loCaseInsensitive,loPartialKey]) ;
  end;
Trainstationdest := AdsTable1.Fieldbyname('Ziele/Linie').asString ;

Destinations := Tstringlist.Create ;
 repeat
       TrainstationDestination := (copy(TrainstationDest,1,pred(pos(',',TrainstationDest))));
       Destinations.Add(TrainstationDestination) ;
       delete(TrainstationDest,1,(pos(',',TrainstationDest))) ;
    until TrainstationDest = '' ;
 // Now the single Information (Destination and Line)
  for I := 0 to Destinations.Count - 1 do
  begin
    Info := Destinations[I] ;
    FinalDestination :=copy(Info,1,pred(pos('/',Info)));
    delete(Info,1,(pos('/',Info))) ;
    Line:= Info;
   nNode := Treeview1.Items.AddChild(nNode,FinalDestination) ;
  end;
Irgendwie wird TForm1.TreeView1Addition aber nicht beim erstellen eines neuen Knotens aufgerufen ( BDS Help ->OnAddition (published) Occurs when new node is added. )
:gruebel: Weitere Vorschläge zu dem Code werden auch gern angenommen ich bin irgendwie mit meinem Wissen am Ende.
Das Ziel koennte man als Broadcast Routing.
(Wikipedia)
Broadcast Routing
Beim Broadcast Routing wird ein Paket an alle Knoten gesendet. Hierbei unterscheiden sich zwei Varianten: Einmal, dass für jeden Knoten ein gesondertes Paket erstellt wird und zum anderen das Fluten. Das Fluten ist hierbei das einfachste Verfahren und ist nicht adaptiv. Jedes eingehende Paket wird auf jeder Übertragungsleitung weitergegeben, außer auf derjenigen, auf welcher es eintraf.


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:10 Uhr.

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