Autor Beitrag
masteroffinalfantasy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mo 31.01.05 19:46 
hi leute nur ma ne kurze frage.
wie ging das nochma mit dem itemaustausch zwischen zwei listboxen?
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mo 31.01.05 20:29 
Tauschen?? So??

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Button1Click(Sender: TObject);
var
text: String;
x, y: Integer;
begin
x := 4;
y := 5;
text := ListBox1.Items.Strings[x];
ListBox1.Items.Strings[x] := ListBox2.Items.Strings[y];
ListBox2.Items.Strings[y] := text;
end;

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mo 31.01.05 20:33 
so ungefähr
deruser soll in der listbox etwas markieren und das soll mittels knopfdruck in die andere liste verschoben werden
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mo 31.01.05 20:43 
Versuch's mal noch n bisschen zu präzisieren! :D

Soll getauscht oder geschoben werden?

Mach's am besten mit Beispiel. z.B. so:

ausblenden Quelltext
1:
2:
3:
4:
5:
+-----+  +-----+
|  1  |  |  1  |
|  2  |  |  2  |
|  3  |  |  3  |
+-----+  +-----+

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mo 31.01.05 20:51 
es soll geschoben werden ,d.h.

1 0
2 0
3 0

dann nach schieben
2 1
3 0
0
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mo 31.01.05 20:55 
Markier das mal als Code, bitte! :D

Und wieso sind bei Nr2 nur noch 5 Values?? :gruebel:

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mo 31.01.05 21:07 
da der wert au list eins gelöscht wurde steht da nur noch 2 werte
Thanatos81
Hält's aus hier
Beiträge: 9

Win XP Pro SP2
Delphi 7 Pro, Delphi 2005 Architect Trial
BeitragVerfasst: Mo 31.01.05 21:45 
Versuchs mal so:
ausblenden Delphi-Quelltext
1:
2:
ListBox2.Items.Add(ListBox1.Items.Strings[ListBox1.ItemIndex]);
ListBox1.Items.Delete(ListBox1.ItemIndex);


Eigentlich wollte ich noch ein Beispiel-Projekt anfügen, hab aber den Upload-Button nicht gefunden :(
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mo 31.01.05 21:50 
alles klar thx
Thanatos81
Hält's aus hier
Beiträge: 9

Win XP Pro SP2
Delphi 7 Pro, Delphi 2005 Architect Trial
BeitragVerfasst: Mo 31.01.05 21:57 
Kein Problem. Brauchste auch noch Code, um alle markierten Einträge zu verschieben?
masteroffinalfantasy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Win XP
Delphi 2005 Architect
BeitragVerfasst: Mo 31.01.05 22:05 
das wär net
und wenn du hier:www.delphi-forum.de/....php?p=212720#212720 helfen könntest wär ich dir äußerst dankbar
Thanatos81
Hält's aus hier
Beiträge: 9

Win XP Pro SP2
Delphi 7 Pro, Delphi 2005 Architect Trial
BeitragVerfasst: Mo 31.01.05 22:24 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  
if ListBox1.SelCount > 0 then  //sicher gehen, dass Einträge markiert sind
    begin
      repeat
        i := 0;  //1. Eintrag hat Index 0
        while (ListBox1.Selected[i] = false) and (i <= ListBox1.Items.Count-1)
          do inc(i);      // solange i erhöhen, bis wir markiertes Element gefunden habe

        ListBox2.Items.Add(ListBox1.Items.Strings[i]);  //in ListBox2 einfügen
        ListBox1.Items.Delete(i);                       //aus ListBox1 löschen
      until ListBox1.SelCount = 0;  //solange etwas markiert ist
    end;


Sollte funzen, geht vielleicht auch einfacher, aber dafür muss ich morgen erst mal wieder Kaffee tanken ;-)

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.

_________________
Wirklich keimfreies Leben gibt es nicht,
entweder man riskiert Läuse oder Langeweile!