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 


Using a listview (object with columns) and setProperty

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Jul 07, 2011 3:47 pm    Post subject: Using a listview (object with columns) and setProperty Reply with quote

a listview is an object that will usually be used for display data ordered in columns (depending on the viewstyle)

Also, sometimes a component has properties you want to access but they are only available to the designer. If for some reason you do not wish to use the designer, but do want access to those properties, you can use the setProperty function.
In this example I use it to access 3 properties not exported specifically to the lua script engine


This example creates a listview with 3 columns and 3 rows
This is just a blunt example, the variable usage can be done a lot smarter, but just showing the easy way for starters

Code:

f=createForm()
lv=createListView(f)
setProperty(lv, 'ViewStyle', 'vsReport') --non lua exported property but you can access it with this
setProperty(lv, 'RowSelect', 'True')
setProperty(lv, 'ReadOnly', 'True')
lvc=listview_getColumns(lv)
column1=listcolumns_add(lvc)
column2=listcolumns_add(lvc)
column3=listcolumns_add(lvc)

listcolumn_setCaption(column1, 'a')
listcolumn_setCaption(column2, 'b')
listcolumn_setCaption(column3, 'c')

lvi=listview_getItems(lv);
row1=listitems_add(lvi)
listitem_setCaption(row1, 'Row 1'); --rw 1 column a
row1_subitems=listitem_getSubItems(row1) --returns a Strings object
strings_add(row1_subitems, 'r1_cb') --row 1 column b
strings_add(row1_subitems, 'r1_cc') --row 1 column c


row2=listitems_add(lvi)
listitem_setCaption(row2, 'Row 2');
row2_subitems=listitem_getSubItems(row2)
strings_add(row2_subitems, 'r2_cb')
strings_add(row2_subitems, 'r2_cc')


row3=listitems_add(lvi)
listitem_setCaption(row3, 'Row 3');
row3_subitems=listitem_getSubItems(row3)
strings_add(row3_subitems, 'r3_cb')
strings_add(row3_subitems, 'r3_cc')

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
happyreadygo
Advanced Cheater
Reputation: 1

Joined: 14 Sep 2011
Posts: 87

PostPosted: Fri Sep 28, 2012 4:41 am    Post subject: Reply with quote

I am new to listview .

this code from your example.
Code:
lvi=listview_getItems(lv);
row1=listitems_add(lvi)
listitem_setCaption(row1, 'Row 1'); --rw 1 column a
row1_subitems=listitem_getSubItems(row1) --returns a Strings object
strings_add(row1_subitems, 'r1_cb') --row 1 column b
strings_add(row1_subitems, 'r1_cc') --row 1 column c


why this code is not like this?

Code:
lvi=listview_getItems(lv);
row1=listitems_add(lvi)
row1_subitems=listitem_getSubItems(row1) --returns a Strings object
strings_add(row1_subitems, 'Row 1') --row 1 column a
strings_add(row1_subitems, 'r1_cb') --row 1 column b
strings_add(row1_subitems, 'r1_cc') --row 1 column c


The ladder seems more understandable for me , or I misunderstand anything ?

ps. how to set listview to display fit to the form , as it now , Only show 5.5 lines of row.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Sat Sep 29, 2012 8:28 am    Post subject: Reply with quote

When adding items like this, think of the first column in the row as the parent. The caption of the first parent is different from the sub-items within the same row. You set the parents caption, then add sub-items to it as a string list.

You can adjust the width and height to the forms using:
Code:

local w,h = control_getSize( f );
control_setSize( lv, w, h );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
happyreadygo
Advanced Cheater
Reputation: 1

Joined: 14 Sep 2011
Posts: 87

PostPosted: Sat Sep 29, 2012 9:12 am    Post subject: Reply with quote

Thank you

Wiccaan wrote:
When adding items like this, think of the first column in the row as the parent.


I try to think like that.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
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 cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites