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.
Wednesday, March 30, 2016
Wednesday, February 3, 2016
Delphi Tutorial work with INI files
Delphi Tutorial work with INI files
In this lesson you can learn how to work with INI files in Delphi.
You can learn how to save settings in application, like window position and size,
controls position and properties etc.
Here is video with all steps :
Here is also code used in this video :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,IniFiles;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Panel1: TPanel;
Edit1: TEdit;
Button8: TButton;
CheckBox1: TCheckBox;
procedure Button7Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyINI:TMemIniFile;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Panel1.top:=Panel1.Top-10;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Panel1.top:=Panel1.Top+10;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Panel1.left:=Panel1.left-10;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Panel1.left:=Panel1.left+10;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
MyINI.EraseSection('Main');
MyINI.UpdateFile;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
MyINI:=TMemIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.ini');
MyINI.WriteInteger('Main','Left',Form1.Left); //Main form left position on screen
MyINI.WriteInteger('Main','Top',Form1.Top); //Main form top position on screen
MyINI.WriteInteger('Main','Width',Form1.Width); //Main form width
MyINI.WriteInteger('Main','Height',Form1.Height); //Main form Height
MyINI.WriteInteger('Panel','Left',Panel1.Left); //Panel left position on screen
MyINI.WriteInteger('Panel','Top',Panel1.Top); //Panel top position on screen
MyINI.WriteString('Panel','Caption',Panel1.Caption); //Panel Caption
MyINI.WriteBool('Check','Checked',CheckBox1.Checked); //Checkbox checked
MyINI.UpdateFile;// Save settings to INI file
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
Panel1.Caption:=Edit1.Text;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyINI:=TMemIniFile.Create(ExtractFilePath(Application.ExeName)+'Settings.ini');
Form1.Left:=MyINI.ReadInteger('Main','Left',Form1.Left); //Main form left position on screen
Form1.Top:=MyINI.ReadInteger('Main','Top',Form1.Top); //Main form top position on screen
Form1.Width:=MyINI.ReadInteger('Main','Width',Form1.Width); //Main form width
Form1.Height:=MyINI.ReadInteger('Main','Height',Form1.Height); //Main form Height
Panel1.Left:=MyINI.ReadInteger('Panel','Left',Panel1.Left); //Panel left position on screen
Panel1.Top:=MyINI.ReadInteger('Panel','Top',Panel1.Top); //Panel top position on screen
Panel1.Caption:=MyINI.ReadString('Panel','Caption',Panel1.Caption); //Panel Caption
CheckBox1.Checked:=MyINI.ReadBool('Check','Checked',CheckBox1.Checked); //Checkbox checked
end;
end.
Saturday, January 30, 2016
Microsoft Excel Tutorial for Beginners formating cell
In this tutorial you can see some basic Excel cells formatting.
Microsoft excel is a powerful tool for data manipulation.
This is just basic way to do this, it is unbelievable how this can be used in more advanced examples.
I use this in my regular work very often.
Microsoft excel is a powerful tool for data manipulation.
This is just basic way to do this, it is unbelievable how this can be used in more advanced examples.
I use this in my regular work very often.
Tuesday, January 26, 2016
Delphi Tutorial Listbox manipulate items
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
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
Tuesday, January 19, 2016
Power resistor DIY
Power resistor DIY
This is one simple way to create power resistor at home.
I needed 0,33 ohm resistor with some larger wattage so I decide to create one, instead of buying one.
I always say, creating is much more fun then buying.
So you need one old high wattage resistor ( I had one 10W 100 ohm ) to use wire from it.You will have to destroy it, and take high resisting wire of desired length-resistance.
You also need some copper wire as connectors.
And you will need jointing filler to create mass for coating, to protect resistor wire from oxidation, and to provide heat transfer from wire to environment.
Also you will need small piece of tin to create mold.
After finishing it will take some day or two to dry
This is one simple way to create power resistor at home.
I needed 0,33 ohm resistor with some larger wattage so I decide to create one, instead of buying one.
I always say, creating is much more fun then buying.
So you need one old high wattage resistor ( I had one 10W 100 ohm ) to use wire from it.You will have to destroy it, and take high resisting wire of desired length-resistance.
You also need some copper wire as connectors.
And you will need jointing filler to create mass for coating, to protect resistor wire from oxidation, and to provide heat transfer from wire to environment.
Also you will need small piece of tin to create mold.
After finishing it will take some day or two to dry
Delphi tutorials create buttons at run time
In this video you will see short practical example of creating buttons at run time in Delphi.
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 an we are ready to go...
It is basic viewer which use Memo component to display text.
Just add Memo, a button and a Open dialog an we are ready to go...
Subscribe to:
Posts (Atom)