Autor Beitrag
Paddymann
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58


Delphi 5 Professional
BeitragVerfasst: So 30.04.06 21:01 
Hallo!
Ich möchte aus einer ListBox eine markierte Zeile löschen. Es gibt ja die Möglichkeit dies mit Items.Delete(i) zu machen jedoch habe ich i ja nicht wenn ich einen Zeile mit der Maus ausgewählt habe.
Wie kann ich das machen?

thx und mfg
patti

P.S.: die SUchfunktion habe ich benutzt.
thkerkmann
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 20

Windows 7
Delphi 2010 Professional
BeitragVerfasst: So 30.04.06 21:37 
Hi,

eine Listbox hat eine Eigenschaft ItemIndex

schon mal danach in der OH gesucht ?

Also dein i = listbox.ItemIndex

Gruss

Thomas.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 01.05.06 08:41 
Hallo,
eine Listbox kennt gleich Deleteselected, kommt auch mit multiselect klar.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Paddymann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58


Delphi 5 Professional
BeitragVerfasst: Mo 01.05.06 11:39 
Das von Thomas hat prima funktioniert. Danke dafür.Nachteil damit ist natürlich dass man damit immer nur ein Item löschen kann. Deshalb habe ich die Variante mit DeleteSelected so ausprobiert:
ausblenden Delphi-Quelltext
1:
ListBox1.Items.DeleteSelected;					


Da kriege ich alleerdings den Fehler undefinierter Bezeichner DeleteSelected.


Noch was anderes:
Ich brauche für eine andere Funktion noch den Caption(oder Name, weiss net genau wie ich das bezeichnen soll) des Items. Gibt es da irgendwie etwas wie "ItemName"?

thx und mfg
Patti
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 01.05.06 11:46 
ich hab geschrieben eine listbox kennt deleteselected. ich habe nicht geschrieben listbox.items kennt deleteselected.

ausblenden Delphi-Quelltext
1:
listbos.items[nr]					

die items beginnen ab 0 zu zählen


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Paddymann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58


Delphi 5 Professional
BeitragVerfasst: Mo 01.05.06 11:49 
ausblenden Delphi-Quelltext
1:
ListBox.DeleteSelected;					


funktioniert aber auch nicht.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 01.05.06 11:54 
funktioniert nicht, sind so ziemlich die genialsten Fehlerbeschreibungen, da weiß ich doch sofort, was du falsch gemacht hast ist . :roll:

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Paddymann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58


Delphi 5 Professional
BeitragVerfasst: Mo 01.05.06 11:55 
sorry...
also der Fehler ist undefinierter Bezeichner: DeleteSelected;
thkerkmann
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 20

Windows 7
Delphi 2010 Professional
BeitragVerfasst: Mo 01.05.06 11:55 
Hi,

@Frank: Deleteselected scheint von der Delphi Version abhängig zu sein.
Zumindest bei meiner Version D5 geht es nicht.

@Paddymann: Wie Frank schon geschrieben hat...
Der Text des ListboxItems wird einfach über Listbox.Items[nr] abgerufen.
wobei nr von 0 bis Listbox.Items.Count-1 laufen sollte.

Gruss
Thomas.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 01.05.06 11:57 
user profile iconthkerkmann hat folgendes geschrieben:
Hi,

@Frank: Deleteselected scheint von der Delphi Version abhängig zu sein.
Zumindest bei meiner Version D5 geht es nicht.



Deleteselected ist ab D6 dabei, bei D5 gibt es es noch nicht, das stimmt. aber Paddymann hat keine Delphi-version ins Profil geschrieben ;-)

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Paddymann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58


Delphi 5 Professional
BeitragVerfasst: Mo 01.05.06 12:07 
OK OK ich bin Schuld^^ Hab Delphi 5... :?

Das mit dem Text von einem Item funktioniert.

Jetztz ist nur noch das Problem dass ich damit jeweils nur eine Datei entfernen kann.
Hat da jmd . noch ne Lösung für Delphi 5?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 01.05.06 12:21 
direkt ins Forum geklimpert, habs nicht ausprobiert. das originale Deleteselected sollte ähnlich aussehen.
jetzt hioer als extra proc, kannst dir auch eine Listbox ableiten und deleteselectd als methode machen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Procedure Proc_ListboxDeleteSelected(Listbox:TListbox);
Var i:integer;
begin
  with listbox do
   if Multiselect then
    begin
      for i:=items.count-1 downto 0 do //Schleife muß rückwärts laufen
       if selected[i] then items.delete(i);
    end
   else
    begin
      if ItemIndex<>-1 then
       items.delete(ItemIndex)
    end;
end;

aufruf:
Proc_ListboxDeleteSelected(Listbox1...);


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Do 04.05.06 17:43 
Titel: ?
Nichts für ungut, aber hierbei handelt es sich nicht um einen Windows API-Befehl!
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Do 04.05.06 19:02 
was willst du damit sagen?

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)