 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
yazigegeda Expert Cheater
Reputation: 0
Joined: 22 Jan 2019 Posts: 183
|
Posted: Fri Aug 02, 2024 8:31 am Post subject: How to set the color of item in listview |
|
|
| 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')
|
I want to set a separate color for Row 2, but the following code doesn't work, help me!
lv.getItem(2).Font.Color=clRed
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Fri Aug 02, 2024 2:30 pm Post subject: |
|
|
give the listview and OnCustomDrawItem property and in there check if Item.Index is 1 (row 2) if so, change the listview Font.Color to clRed
_________________
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 |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1528
|
Posted: Mon Aug 05, 2024 8:38 am Post subject: |
|
|
Here is an excerpt from @DB's relevant code:
| Code: | if s2 then s2.Destroy() end
s2=createForm()
lv=createListView(s2)
lv.ViewStyle='vsReport'
lv.RowSelect=true
lv.HideSelection=false
c=lv.Columns.add()
c.Caption='C1';
c=lv.Columns.add()
c.Caption='C2';
c=lv.Columns.add()
c.Caption='C3';
------------------------------------------------------
local listclrTbl1 = {}
for i=1,10 do
l=lv.Items.add()
l.Caption='bla'..i;
l.SubItems.add('line '..i)
l.SubItems.add('i*2='..i*2)
listclrTbl1[i] = {"0x0","0x0","0x0"}
end
function cptColor(idx,clr)
listclrTbl1[idx][1] = clr
end
function subColor(idx1,idx2,clr)
idx3 = tonumber(idx2) + 1
listclrTbl1[idx1][idx3] = clr
end
-----------------------------------------------------------------
cptColor(3,0x0000ff)
cptColor(6,0xf56060)
subColor(4,1,16711935)
subColor(5,2,16776960)
lv.OnCustomDrawItem=function(sender, ListItem, state, DefaultDraw)
sl1 = tonumber(ListItem.Index) + 1
if sl1 then
sender.canvas.font.color=listclrTbl1[sl1][1]
end
return true
end
lv.OnCustomDrawSubItem=function(sender, ListItem, SubItemIndex, state, DefaultDraw)
sl2 = tonumber(ListItem.Index) + 1
sl3 = SubItemIndex
if sl2 then
if sl3==1 then
sender.canvas.font.color=listclrTbl1[sl2][2]
else
sender.canvas.font.color=listclrTbl1[sl2][3]
end
end
return listclrTbl1
end
subColor(6,1,clRed) |
_________________
|
|
| Back to top |
|
 |
|
|
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
|
|