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:
Delphi Tutorial work with INI files(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement… Read More
Delphi tutorials create buttons at run time In this video you will see short practical example of creating buttons at run time in Delphi. … Read More
Delphi Tutorial Listbox manipulate itemsDelphi 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, a… Read More
Delphi - create simple image viewer In this video I will show you how to create simple image viewer. You have to add jpeg and gifimage,and pngimage in uses section. here is the link… Read More
Delphi - Create simple text viewer Let's create simple text viewer with Delphi. It is basic viewer which use Memo component to display text. Just add Memo, a button and a Open dialog a… Read More
0 comments:
Post a Comment