Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.02.08 14:29 
Hi, Delpher,

es gibt doch die Möglichkeit, in einer Tabelle statt table1.fields[2]... auch zu sagen:
table2.fieldbyname('Name')....

gibt es die Möglichkeit, bei einem Popupmenü den obigen Befehl auch mit dem Itemnamen aufzurufen, etwa popupmenu6.itembyname('Sortieren').enabled := true; ?
(So natürlich nicht :cry: )

Danke für eine Idee!
Detlef
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 22.02.08 14:42 
das soltle über findcomponent gehen

ausblenden Delphi-Quelltext
1:
Form1.FindComponent('Sortieren') As TMenuItem).Enabled:= True;					
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.02.08 15:03 
Danke für deine schnelle Antwort, IronWulf!

Kleine Zusatzfrage: Was ist wenn der Itemeintrag 'Sortieren' in Popupmenu3 und in Popupmenu5 vorkommt? :shock:

Bis "gleich" ?

Detlef
Nico72
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50

Win XP, Vista
Delphi 7, Delphi 2006
BeitragVerfasst: Fr 22.02.08 15:57 
Hallo,

FindComponent ist eine Methode von TComponent, also auch von TPopUpMenu. So kannst du deine Suche auf eine Komponente eingrenzen.
Nico72
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50

Win XP, Vista
Delphi 7, Delphi 2006
BeitragVerfasst: Fr 22.02.08 16:03 
Na so ein Quatsch.. :oops:
es gibt keine zwei Komponenten mit den selben Namen im Formular...
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.02.08 16:32 
Aha, oben ist eine Klammer zu viel,

Detlef
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Fr 22.02.08 17:01 
Äh, ich versteh den Sinn nicht so ganz. Warum machst du es nicht so:

ausblenden Delphi-Quelltext
1:
Sortieren.Enabled := True;					
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.02.08 17:42 
Hi, also gelöst habe ich es jetzt so:

ausblenden Delphi-Quelltext
1:
with form1.FindComponent('Sortieren1') As TMenuItem do Enabled := false;					


Vielen Dank noch mal! (bes. an IronWulf)
Detlef
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Fr 22.02.08 20:44 
Tschuldigung, wenn ich noch frage, obwohl der Thread schon als gelesen markiert wurde.

Du magst es wohl besonders kompliziert, oder? :nixweiss:

Wenn du Zugriff zur Form-Klasse hast (was normalerweiße der Fall ist), klaptt es doch ohne Probleme so:

ausblenden Delphi-Quelltext
1:
Form1.Sortieren.Enabled := True					

Mir fällt jetzt aber wirklich kein Fall ein, in dem du kein Zugriff auf die Variablen der Komponenten auf der Form hast. Wenn du nur eine TForm an eine Prozedur übermittelt bekommst, klappt folgendes:

ausblenden Delphi-Quelltext
1:
(Form as Form.ClassType).Sortieren.Enabled := True;					

(Das setzt zwar vorraus, dass die Klasse der Form die Komponente Sortieren hat, aber das wird ja bei FindComponent auch vorrausgesetzt.

Wenn du aber unbedingt FindComponent nehmen willst - warum auch immer - dann kannst du user profile iconIronwulfs Lösungsvorschlag fast 1:1 übernehmen. Er hat nur eine einleitende Klammer vergessen:

ausblenden Delphi-Quelltext
1:
(Form1.FindComponent('Sortieren') As TMenuItem).Enabled:= True;					

Die with-Konstruktion ist da sinnlos.

Grüße,
Yogu
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 22.02.08 22:31 
Hi, Yogu

jetzt ist es mir endlich klar! [Nein, ich mag es nicht besinders kompliziert]

Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas