Autor Beitrag
Daniel_100
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Sa 01.02.03 23:40 
Hallo!

Kann man Einträge, z.B. aus Listboxen, in ein MainMenu einbauen?: :roll:

user defined image

Wenn ja, was für ein Code muss dann Button1Click zugewiesen werden?

Danke
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 01.02.03 23:54 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var item:tmenuitem;
begin
item:=tmenuitem.create(mainmenu1);
item.caption:=listbox1.items[integervar];
mainmenu1.Items[0].add(item);
oder:
mainmenu1.Items.add(item);
end;


8)

Fiji-Fighter
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 02.02.03 07:55 
Der Code funktioniert nicht, da der "integervar" kein Wert zugewiesen ist (Wert: 4358644)!!! :(
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 02.02.03 08:58 
Wenn du die Lösung eigentlich schon weißt:
Zitat:
da der "integervar" kein Wert zugewiesen ist

Warum wendest du sie dann nicht an?

Kann man bei dir mehrere Einträge aus der Listbox wählen?
Nein. Dann solltest du dir mal die Eigenschaft "ItemIndex" ansehen.
Ja. Dann brauchst du vielleicht eine Schleife, die alle Items durchgeht und die ausgewählten in das Menü aufnimmt.

Der Code funktioniert.
Der Fehler liegt ganz einfach nur bei dir.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: So 02.02.03 15:26 
integervar ist eine Integervariable, der du den Wert zuweist, den die markierte Zeile in der Listbox hat!!!
Also so:
ausblenden Quelltext
1:
integervar:=listbox1.itemindex;					

oder wenn du einfach den ersten eintrag hinzufügen willst könntest du das auch so schreiben:
ausblenden Quelltext
1:
item.caption:=listbox1.items[0];					


oder habe ich das Problem net verstanden???

Fiji-Fighter
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 02.02.03 15:55 
Ob ich nun
Zitat:
ausblenden Quelltext
1:
integervar:=listbox1.itemindex;					
oder
Zitat:
ausblenden Quelltext
1:
item.caption:=listbox1.items[0];					
eingebe: Bei beiden wird jedes mal nur der erste Eintrag hinzugefügt. Ich wollte gerne alle Einträge auf einmal hinzufügen.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: So 02.02.03 15:58 
alle... sag das doch gleich ;)

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
...
for i:=0 to (listbox1.items.count-1) do
begin
item.caption:=listbox1.items[i]; 
mainmenu1.Items[i].add(item); 
end;
...


so sollte es klappen ;)

Fiji-Fighter
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 02.02.03 16:08 
Also der Code sieht jetzt so aus:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
for i:=0 to (listbox1.items.count-1) do
begin
intv:=listbox1.itemindex;
item:=tmenuitem.create(mainmenu1);
item.caption:=listbox1.items[i];
mainmenu1.Items.Add(item);
end;


So werden die Einträge direkt ins Mainmenu eingetragen, oder?
Ich wollte die Einträge aber gerne ins Menü "Einträge" hinzufügen (siehe Bild oben).
Geht das auch?
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: So 02.02.03 16:13 
Ist schon gut. Ich habs herausgefunden!

VIELEN DANK

Moderiert von user profile iconTino: Formatierungs-Tags entfernt.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: So 02.02.03 16:17 
nicht ganz...

du solltest auf jeden fall nicht jedesmal neu das item createn...

so sollte es aussehen... (war wahrscheinlich net gut erklärt ;))
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var item:tmenuitem; 
begin 
item:=tmenuitem.create(mainmenu1); 
 for i:=0 to listbox1.items.count do
 begin
  item.caption:=listbox1.items[i];  
  mainmenu1.Items[0].add(item); 
 end;
end;