Autor |
Beitrag |
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Di 13.02.07 21:31
Habe bei TListView keine Methode gefunden, zwei Einträge zu vertauschen.
So gibt es z.B. bei TListbox Exchange.
Muss ich sowas selber implementieren oder habe ich etwas übersehen?
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Mi 14.02.07 00:47
Hallo,
da gibt es keine Methode.
Änder doch den Code in dem Beitrag in der Library entsprechend:
ListView-Item nach oben oder unten verschieben
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Mi 14.02.07 11:49
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38:
| procedure MoveLVItem(LV: TListView; Direction: TSearchDirection); var aItem, NextItem,TmpItem : TListItem; begin with LV do begin if IsEditing or not Assigned(ItemFocused) then exit; aItem := ItemFocused; case Direction of sdAbove : if aItem.Index = 0 then exit; sdBelow : if aItem.Index = Items.Count-1 then exit; end; NextItem := GetNextItem(aItem,Direction,[isNone]); Items.BeginUpdate; try TmpItem := TListItem.Create(Items); TmpItem.Assign(NextItem); NextItem.Assign(aItem); aItem.Assign(TmpItem); aItem.Selected := NextItem.Selected; TmpItem.Free; NextItem.MakeVisible(True); ItemFocused := NextItem; Selected := NextItem; finally Items.EndUpdate; end; end; end;
procedure Tform_clmanager.btn_att_upClick(Sender: TObject); begin MoveLVItem(listview_att,sdAbove); end; |
Aber es funktioniert nicht.  Es passiert einfach nichts. (Ja, ich habe ein Item markiert.  )
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Mi 14.02.07 14:17
Hallo,
setz doch mal einen Haltepunkt in Zeile 7, dann weiter mit F7.
In welcher Zeile steigt er aus, in Zeile 8,12 oder 14?
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Mi 14.02.07 14:24
In Zeile 8
Es ist garantiert eines markiert. Und was das mit IsEditing auf sich hat, kann ich nicht sagen.
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Mi 14.02.07 18:01
Hallo,
zu IsEditing, schau mal den Kommentar im Code
Delphi-Quelltext 1: 2:
| if IsEditing or not Assigned(ItemFocused) then exit; | wenn der InplaceEditor der ListView aktiv ist, kann es Probleme mit dem Verschieben von Items geben.
Setz mal vorm Funktionsaufruf den Focus auf die ListView:
Delphi-Quelltext 1: 2:
| listview_att.Setfocus; MoveLVItem(listview_att,sdAbove); |
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
|