Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Tutorial] Using ListView!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Tue Jul 24, 2007 9:58 am    Post subject: [Tutorial] Using ListView! Reply with quote

TListView

This is a basic tutorial on how to use ListView.

ListView

Drop a ListView on an empty form and 3 buttons, now lets start.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
 NewItem:TListitem;
begin
NewItem := ListView1.Items.Add;
NewItem.Caption := 'Hello';
NewItem := ListView1.Items.Add;
NewItem.Caption := 'again';
NewItem := ListView1.Items.Add;
NewItem.Caption := 'World';
end;

With this code we add 3 Items to your ListView, if you try run the program and click on Button1 you'll see that the items is added. Now to make it look even nicer you can drop a ImageList1 on your form and set the height and width to 32x32 and add 3 images with the size 32x32. Then in your Object Inspector (while having ListView marked) you click on LargeImages (It has red text) and choose ImageList1 or whatever you called it. If you run the program now, you will see that it got the images above the text, but if you want to control which icon is used, use this code by adding it after each "Add"
Code:
 
NewItem.ImageIndex := 2;

Now you get the image with the number 2 on the place where you want it. You can change the way the ListView shows it data by marking ViewList and choose "ViewStyle" in the object inspector.

If you want the text the Item in the ListView is named in a Edit box, use this code (Hard to explain, try it out yourself)
Code:

If ListView1.Selected = nil then exit;
Edit1.Text := ListView1.Selected.Caption;

The first line is pretty important. If you try acces the choosen item, without theres any there will be an error, therefor using the first line it will automaticly jump out of the procedure if nothing has been choosen. If theres a choosen item the caption of the Item will get displayed in the edit box.

To delete an item from the ListView is pretty simple, double click button2 and write this:
Code:

If ListView1.Selected = nil then exit; //Remeber this now!
ListView1.Selected.Delete;


If you want to delete a certain item, it can be done this way:
Code:

ListView1.Items[1].Delete;

With that code we delete Item number 1. Thats way to easy, so lets try do it a bit more advanced. Set ListView's multiselect to true. That makes us able to select more than 1 item by using Shift and Control. Use the following code to delete the choosen items:
Code:

var
 i,v:integer;
begin
for i := 0 to ListView1.SelCount - 1 do
begin
  V := ListView1.Selected.Index;
  ListView1.Items[v].Delete;
end;


That covers pretty much it. Tell me if you get any errors and if you like it or not, because it might encourage me to make more tutorials about other features in delphi.

[Credits: www.udvikleren.dk for the codes and teaching me to use ListView!]


Last edited by Kevin on Tue Jul 24, 2007 10:13 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Jul 24, 2007 10:12 am    Post subject: Re: [Tutorial] Using ListView! Reply with quote

nice Razz

Kevinnn wrote:
TListView

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
 NewItem:TListitem
begin
NewItem := ListView1.Items.Add;
NewItem.Caption := 'Hello';
NewItem := ListView1.Items.Add;
NewItem.Caption := 'again';
NewItem := ListView1.Items.Add;
NewItem.Caption := 'World';
end;



You forgot a semicolon Very Happy at var's.
Back to top
View user's profile Send private message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Tue Jul 24, 2007 10:13 am    Post subject: Reply with quote

oh yea ... Lol. I'll edit it now.
Back to top
View user's profile Send private message MSN Messenger
Simsgy
Grandmaster Cheater
Reputation: 0

Joined: 07 May 2007
Posts: 581
Location: My new avatar <3

PostPosted: Fri Jul 27, 2007 11:13 am    Post subject: Reply with quote

Very nice tut!
I will read it after the Delphi 2007 will be done downloading (3 hours).
GJ.

_________________

Designer, WebMaster and a Delphi programmer.
TrPlayer, my biggest Delphi project hosted on SourceForge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Fri Jul 27, 2007 12:18 pm    Post subject: Reply with quote

thanks alot Wink i appreciate every kind of feedback.
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Jul 27, 2007 3:41 pm    Post subject: Reply with quote

Wtf..... ?

dude thanks so much !!! ive allways searched this TuT T_T..

now i know how to use a ListView !, without you i couldnet know ever Sad

please make a next tut when delphi 2008 comes out on how to use buttons, ok Smile ?

P.S - CodeGear's Delphi 2007 sucks.
Back to top
View user's profile Send private message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Fri Jul 27, 2007 3:43 pm    Post subject: Reply with quote

thanks.

"please make a next tut when delphi 2008 comes out on how to use buttons, ok ?" - is that sarcastic ?
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Jul 27, 2007 3:45 pm    Post subject: Reply with quote

Kevinnn wrote:
thanks.

"please make a next tut when delphi 2008 comes out on how to use buttons, ok ?" - is that sarcastic ?


yes.

Kevinnn, i hope you're going to to fill/spam this section with TuT's on how to use all Delphi Objects/Tools/VCL components, no offence, people can just google or learn from www.delphibasics.co.uk


Last edited by DeletedUser14087 on Fri Jul 27, 2007 3:46 pm; edited 2 times in total
Back to top
View user's profile Send private message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Fri Jul 27, 2007 3:46 pm    Post subject: Reply with quote

so you mean its a noob tut?
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Jul 27, 2007 3:46 pm    Post subject: Reply with quote

Kevinnn wrote:
so you mean its a noob tut?


It is a tut for beginners in delphi.
Back to top
View user's profile Send private message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Fri Jul 27, 2007 3:49 pm    Post subject: Reply with quote

well at least i have accomplished my goal. Making a tutorial which aint too hard for you, or was it too hard ?

RazzRazz Joke.
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Jul 27, 2007 3:51 pm    Post subject: Reply with quote

Kevinnn wrote:
well at least i have accomplished my goal. Making a tutorial which aint too hard for you, or was it too hard ?

RazzRazz Joke.


Umm...dude.

Why would anyone NOT know how to use a ListView ? every single VCL object is explained to you if you press Fone at Delphi lol.
Back to top
View user's profile Send private message
KingZero
Expert Cheater
Reputation: 0

Joined: 27 Jun 2006
Posts: 103

PostPosted: Fri Jul 27, 2007 7:15 pm    Post subject: Reply with quote

Kaspersky wrote:

P.S - CodeGear's Delphi 2007 sucks.

You suck too.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Jul 27, 2007 7:40 pm    Post subject: Reply with quote

This is good, the list view control is a pain in the ass to work out at first.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sat Jul 28, 2007 4:24 am    Post subject: Reply with quote

KingZero wrote:
Kaspersky wrote:

P.S - CodeGear's Delphi 2007 sucks.

You suck too.


I didnt made any Delphi software, so i cant suck.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites