Delphi Tutorial Listview
In this tutorial you can learn how to work with Listview in Delphi.
You can learn how to create,edit and delete items, and also how to add icons to items.
Here is video with steps :
Here is also code used in this video :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, Menus, StdCtrls, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
CheckBox1: TCheckBox;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
ImageList1: TImageList;
Button10: TButton;
CheckBox2: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure ListView1DblClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure ListView1Edited(Sender: TObject; Item: TListItem; var S: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button10Click(Sender: TObject);
var
Itm:TListItem;
i:Integer;
begin
for I := 1 to 10 do
begin
Itm:=ListView1.Items.Add;
Itm.Caption:='Item '+IntToStr(ListView1.Items.Count);
Itm.SubItems.Add(Itm.Caption+' Subitem 1');
Itm.SubItems.Add(Itm.Caption+' Subitem 2');
Itm.ImageIndex:=0;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Itm:TListItem;
begin
Itm:=ListView1.Items.Add;
Itm.Caption:='Item '+IntToStr(ListView1.Items.Count);
Itm.SubItems.Add(Itm.Caption+' Subitem 1');
Itm.SubItems.Add(Itm.Caption+' Subitem 2');
Itm.ImageIndex:=0;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListView1.DeleteSelected;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ListView1.Items.Clear;
end;
procedure TForm1.Button4Click(Sender: TObject);
var i:Integer;
begin
for I := 0 to ListView1.Items.Count-1 do
begin
ListView1.Items[i].Checked:=True;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var i:Integer;
begin
for I := 0 to ListView1.Items.Count-1 do
begin
ListView1.Items[i].Checked:=False;
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
ListView1.ViewStyle:=vsIcon;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
ListView1.ViewStyle:=vsList;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
ListView1.ViewStyle:=vsReport;
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
ListView1.ViewStyle:=vsSmallIcon;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
ListView1.Checkboxes:=CheckBox1.Checked;
end;
procedure TForm1.CheckBox2Click(Sender: TObject);
begin
ListView1.RowSelect:=CheckBox2.Checked;
end;
procedure TForm1.ListView1DblClick(Sender: TObject);
begin
if ListView1.ItemFocused.Checked=true then
ListView1.ItemFocused.Checked:=false
else
ListView1.ItemFocused.Checked:=True;
end;
procedure TForm1.ListView1Edited(Sender: TObject; Item: TListItem;
var S: string);
begin
Item.SubItems[0]:=
S+' Subitem 1';
Item.SubItems[1]:=
S+' Subitem 2';
end;
end.
Popular Posts
-
This is an example of media player created in Delphi using VLC multimedia player ActiveX library. For this to work VLC player and its A...
-
Visit my Youtube channnels : Electro_Magic ; Practical Tips ; Delphi practical school This is example how one can export ima...
-
An example of exporting sql database table ( in this case sqlite table ) to MS Excel. Link to full source : Source code Here ...
Recent Posts
Categories
- ADC (Analog-to-Digital Converter)
- Algebra
- Algebraic Manipulation
- Analog Input
- C/C++ Programming
- connect sqlite
- convert pdf to jpg on mac
- Curve Fitting
- Delphi
- Delphi tutorial
- DIY
- Electronics
- Embedded Systems
- Engineering Mathematics
- Equations
- export data to excel
- Export database
- Export database to Excel Delphi tutorial
- export images from pdf
- export pdf to jpg
- export sql to
- export to excel
- Graphing Functions
- importing ex
- Mathematical Modeling
- Mathematics
- media player
- Microcontroller
- movie player
- PCB
- Physics Applications
- Polynomial Addition
- Programming
- Programming Example
- Read Analog Code
- Sample Code
- saving a jpeg as a pdf
- sql import from excel
- sql query export to excel
- sqlite jdbc driver
- sqlite multiple connections
- sqlite odbc driver
- SQLite with ZEOS library
- sqlite3 connection
- sqliteconnection
- STM32 Development
- STM32CubeMX
- STM32G030
- Styrofoam cutter
- Styrofoam cutter DIY
- Toner transfer
- video player
- video player for windows
- windows media player
- windows multimediamovie player for windows 10
Unordered List
Text Widget
Pages
Blog Archive
- March 2024 (1)
- June 2023 (1)
- February 2021 (1)
- November 2020 (1)
- October 2020 (1)
- August 2020 (1)
- April 2018 (1)
- January 2018 (1)
- December 2017 (1)
- November 2017 (3)
- October 2017 (3)
- September 2017 (1)
- August 2017 (1)
- May 2017 (2)
- April 2017 (1)
- February 2017 (1)
- December 2016 (3)
- November 2016 (1)
- October 2016 (1)
- September 2016 (2)
- June 2016 (1)
- May 2016 (1)
- March 2016 (1)
- February 2016 (1)
- January 2016 (7)
Search This Blog
Powered by Blogger.
0 comments:
Post a Comment