Autor Beitrag
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Fr 25.07.03 16:08 
Hallo,

Entweder stehe ich grad' vollkommen auf'm Schlauch, oder die Listboxes gefallen mir nicht so ganz... :roll:
Ich möchte einen Eintag umbenennen. Das geht ja so:
ausblenden Delphi-Quelltext
1:
Listbox.Items[n] := SomeString;					

Allerdings benutzt die VCL da anscheinend die Nachricht LB_DELETESTRING, die die Listbox an die nächste Stelle scrollt, an der der Auswahlbalken sichtbar ist. Ist der erste Eintrag gerade markiert, befindet man sich in der Liste aber ganz am Ende, wird beim Ändern eines Eintrages die Listbox automatisch zum Anfang gescrollt.
Das ist natürlich dann sinnvoll, wenn man den Eintrag ändern will, der gerade markiert ist, aber mehr als störnd, wenn sich die Auswahl nicht ändern darf und man einen anderen Eintrag ändern will.

Weiß jemand was, wie man einen Eintrag einer Listbox ändern kann, ohne daß man die Auswahl ändern muss und ohne daß automatisch irgendwoanders hingescrollt wird?

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
kasi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37

Win XP
D5 Ent
BeitragVerfasst: Fr 25.07.03 18:42 
Kleiner Workaround
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var
  TopItem: integer;
begin
  TopItem := SendMessage(ListBox1.Handle, LB_GETTOPINDEX, 0, 0);
  ListBox1.Items[10] := 'wert';
  SendMessage(ListBox1.Handle, LB_SETTOPINDEX, TopItem, 0);
end;

KASI
tommie-lie Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Fr 25.07.03 19:02 
Auf so eine abwegige Idee bin ich gar nicht gekommen :mrgreen:
Zwar ein beschissener Workaround, aber besser als gar nichts...
Danke!!

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
eddyp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 58



BeitragVerfasst: Mi 30.07.03 17:58 
einfacher bei strings
ausblenden Delphi-Quelltext
1:
2:
3:
i:=listbox.itemIndex;
wert:='neuer Text';
listbox.items.strings[i]:=wert;


Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.

_________________
Grüsse, eddyp
tommie-lie Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 30.07.03 18:22 
Nee, ich will ja nicht da etwas ändern, wo gerade der Auswahlbalken ist.
Ich will, irgendwo etwas ändern und dabei nicht automatisch zum Auswahlbalken gescrollt werden.
Ein kleiner aber feiner Unterschied ;-)

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert