AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Listbox editierbar machen

Ein Thema von Wittlich · begonnen am 8. Sep 2003 · letzter Beitrag vom 8. Sep 2003
Antwort Antwort
Wittlich

Registriert seit: 8. Sep 2003
2 Beiträge
 
#1

Listbox editierbar machen

  Alt 8. Sep 2003, 18:29
Hallo,

ich möchte eine Listbox editierbar machen. Zur Laufzeit soll mein Programm es ermöglichen mehrere Zeilen Text in eine Listbox einzugeben.
Ich dachte, das geht so wie bei Stringgrid über options und goediting, aber leider gibt es bei Listbox keine options, hm.

Wer weiß Rat?
Danke im Voraus
Wittlich
  Mit Zitat antworten Zitat
Dagon

Registriert seit: 13. Jul 2003
505 Beiträge
 
Delphi 7 Professional
 
#2

Re: Listbox editierbar machen

  Alt 8. Sep 2003, 18:42
du musst wohl zuerst die werte in ein edit-feld eingeben lassen. und dann anschliessend den string in die listbox übergeben!
  Mit Zitat antworten Zitat
Alexander

Registriert seit: 28. Aug 2002
Ort: Oldenburg
3.513 Beiträge
 
Turbo Delphi für .NET
 
#3

Re: Listbox editierbar machen

  Alt 8. Sep 2003, 18:53
Probier das mal so:
Delphi-Quellcode:
{NOTE : This will also work with an OwnerDraw ListBox
But be sure you "pad" the Left Property of the Edit so
Any icons etc, do not get covered up by the TEdit.
And also be aware that there will be a bit of "flashing"
if you do use an OwnerDraw ListBox}
 

{This is in a Popup menu.} 
procedure TForm1.Change1Click(Sender: TObject);
var
  I9: Integer;
  ColInt: Integer;
  LRect: TRect;
begin
  LRect := ListBox1.ItemRect(ListBox1.ItemIndex);
  {Set the size of the TEdit} 
  Edit1.Top := LRect.Top + 1;
  Edit1.Left := LRect.Left + 1;
  Edit1.Width := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[ListBox1.ItemIndex]) + 6;
  Edit1.Height := (LRect.Bottom - LRect.Top) + 1;

  Edit1.Text := ListBox1.Items.Strings[ListBox1.ItemIndex];
  ListBox1.Selected[ListBox1.ItemIndex] := False;
  Edit1.Visible := True;
  Edit1.SelectAll;
  Edit1.SetFocus;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  Edit1.Visible := False;
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
  I8: Integer;
begin
  if Key = #13 then
  begin
    I8 := ListBox1.ItemIndex;
    ListBox1.Items.Delete(ListBox1.ItemIndex);
    ListBox1.Items.Insert(I8, Edit1.Text);
    Edit1.Visible := False;
    Key := #0;
  end;
end;
Alexander
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz