![]() |
Problem mit ListBox
Guten Morgen @all.
Ich habe auf ein Formular eine ListBox gesetzt, kann aber zur Laufzeit keine Eingaben machen. Was habe ich da falsch gemacht? Dankbar für jeden Tip ist Jürgen |
Re: Problem mit ListBox
Du meinst editieren ? dafür ist die Listbox nicht gedacht vieleicht wäre Stringgrid ja was für deine Zwecke.
|
Re: Problem mit ListBox
Hallo,
ein TListView wäre dafür auch geeignet. |
Re: Problem mit ListBox
Moin Jürgen,
direkt in der ListBox ändern kannst du zwar nicht, aber manchmal will man das auch gar nicht.
Delphi-Quellcode:
Freundliche Grüße
procedure TDemoForm.ListBoxDblClick(Sender: TObject);
var s: string; begin with Sender as TListBox do if ItemIndex > -1 then begin s := Items[ItemIndex]; if InputQuery('Bearbeiten', 'Text', s) then Items[ItemIndex] := s; end; end; |
Re: Problem mit ListBox
Zitat:
TListView mit einer Spalte (AutoSize := True) ViewStyle := vsReport RowSelect := True ShowColumnHeaders := False |
Re: Problem mit ListBox
@marabu, schöne Idee. :thumb:
|
Re: Problem mit ListBox
Guten Morgen,
und vielen Dank für die schnellen Antworten. Da habe ich wohl etwas falsch verstanden: Zitat:
Gruß Jürgen |
Re: Problem mit ListBox
Ein Item kannst du so löschen:
Delphi-Quellcode:
Listbox1.Items.Delete(ItemIndex);
|
Re: Problem mit ListBox
Danke für die Antworten - ich dachte ListBox sei viel komfortabler (z.B. markierten + entf + weg isses).
|
Re: Problem mit ListBox
Du musst nur wissen, was du willst.
So kann z.B. eine Tastaturschnittstelle ausehen:
Delphi-Quellcode:
procedure TDemoForm.ListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); var s: string; i: Integer; begin with Sender as TListBox do case Key of VK_INSERT: begin s := ''; if InputQuery('Hinzufügen', 'Text', s) then if Trim(s) <> '' then Items.Insert(ItemIndex, s); end; VK_DELETE: if ItemIndex > -1 then Items.Delete(ItemIndex); VK_SPACE: begin s := Items[ItemIndex]; if InputQuery('Bearbeiten', 'Text', s) then if Trim(s) <> '' then Items[ItemIndex] := s; end; VK_UP: if (ItemIndex > 0) and (ssCtrl in Shift) then begin i := ItemIndex; Items.Exchange(Pred(ItemIndex), ItemIndex); ItemIndex := i; end; VK_DOWN: if (Succ(ItemIndex) < Count) and (ssCtrl in Shift) then begin i := ItemIndex; Items.Exchange(Succ(ItemIndex), ItemIndex); ItemIndex := i; end; end; // Key := 0; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:57 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz