Delphi Tutorial Listbox manipulate items
In this video you can learn how to manipulate with Listbox items in Delphi.
You can learn how to add one, add multiple items, delete one or all items , so as save items to and load from text file.
Here is also code used in this video :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Button3: TButton;
Edit2: TEdit;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Add('Item - '+IntToStr(ListBox1.Items.Count));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Items.Add(Edit1.Text);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i:Integer;
begin
ListBox1.Items.Clear; // clear all items in listbox first
for I := 1 to StrToInt(Edit2.Text) do
begin
ListBox1.Items.Add('Item - '+IntToStr(i));
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
ListBox1.Items.Clear;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
if SaveDialog1.Execute then
SaveDialog1.InitialDir:='C:\Temp\';
ListBox1.Items.SaveToFile(SaveDialog1.FileName);
ListBox1.Items.Clear;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
ListBox1.Items.Clear;
if OpenDialog1.Execute then
OpenDialog1.InitialDir:='C:\Temp\';
ListBox1.Items.LoadFromFile(OpenDialog1.FileName);
end;
end.
Music in video by :
bensound-theelevatorbossanova
www.bensound.com
Delphi Tutorial Listbox manipulate items
Related Posts:
Web browser Delphi Example (Tip for 10 ) As you will see, it is possible to create simple Web browser very quickly using Delphi and component TWebBrowser , which encapsulates Internet Expl… Read More
Form in a DLL file Delphi tutorials (Tip for 10 ) (adsbygoogle = window.adsbygoogle || []).push({}); In this example you can see how to create dll file with form in it , and call t… Read More
Music Player using BASS library Delphi tutorial (Tip for 10 ) Delphi mp3 music player Example how to create mp3 player with Delphi and BASS library. BASS library can be downloaded from : http://www.un4… Read More
Video Player using Direct Show DSPack component for Delphi (Tip for 10 ) - Example of media player created with Delphi and DSPack components. - You can download component from: https://github.com/ms301/dspack - … Read More
VirtualStringTree as Grid - Delphi tutorial (Tip for 10 ) In this example you can learn how to use Virtualstringtree from GemSoft as a Grid. This component can be used as a regular tree view but al… Read More
0 comments:
Post a Comment