|
Forum
Grundkurs
»Introduktion
»Snabbguide
»Komponenter
»Händelser
»Strängar
»Räkna med Delphi »Egna
typer
»Selektion
»Iteration
»Menyer
»Funktioner
»Arraystrukturer
Tips & Tricks
»Nya tips
»Blandat
»Databaser
»Filer
»Forms
»Grafik
»Internet
»Komponenter
»Matematik
»Multimedia
»Objekt/ActiveX
»Skrivare
»Strängar
»System
»Mest lästa tips
Artiklar
»Delphi och ADO
»Bygga en DLL
»Skapa en enkel rapport
»Hantera registret
»Enheter, units
»Klassen TCanvas
»Använd LookUp Controls
Nya
tips
Lägg
till tips
Delphilänkar
Gästbok
|
|
|
|
|
|
Skapa en listbox som kan uppdateras
|
Kategori: Komponenter
Inlagt: 2002-08-12
Läst: 561
Inlagt av: Staffan Berg
|
|
Beskrivning |
|
Med denna kod kan du skapa en listbox som kan uppdateras.
|
|
Kod |
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
ifKey = #13 then
begin
I8 := ListBox1.ItemIndex;
ListBox1.Items.Delete(ListBox1.ItemIndex);
ListBox1.Items.Insert(I8, Edit1.Text);
Edit1.Visible := False;
Key := #0;
end;
end;
|
|
|