PDA

View Full Version : dotNet listview items


baotd86
02-20-2012, 09:03 AM
I have a script here

thePath = getsavePath()
if thePath != undefined do
(
theFiles = getFiles (thePath+"\\*.max") --
rollout DE_Dl3 "Untitled" width:460 height:480
(
--Create the dotNet listview control
label lb3 "1 / Check files to delete" pos:[18,10] height:25
dotNetControl lv "system.windows.forms.listView" height:400
button del "2 / Delete the files checked" width:200 height:21 pos:[18,450]
fn initLv Lv =
(
--Setup the forms view
Lv.view=(dotNetClass "system.windows.forms.view").details
Lv.FullRowSelect=true --Set so full width of listView is selected and not just first column.
Lv.GridLines=true --Show lines between the items.
Lv.MultiSelect=true --Allow for multiple selections.
Lv.Checkboxes = true
)

--Add columns.
fn addColumns Lv columnsAr=
(
w=(Lv.width/columnsAr.count)-1 --Calculate the width of each column.
for x in columnsAr do --Loop through all the column names to be added.
(
Lv.columns.add x w --Add each new column to the listview control.
)
)

--Adds rows of data to the listView
fn populateList Lv=
(
rows=#() --Empty array to collect rows of data
for f in theFiles do --Loop through all the objects in the scene.
(
filename = filenameFromPath f
li=dotNetObject "System.Windows.Forms.ListViewItem" filename --Create a listViewItem object and name it.
li.subitems.add (((GetFileSize f)/1024) as string + " KB") --Add data to the second column.
append rows li --Added the listViewItem to the rows array

)
Lv.items.addRange rows --Add the array of rows to the listView control.
)
on DE_Dl3 open do
(
initLv Lv
addColumns Lv #("File name","Size")
populateList Lv
)

on del pressed do
(
for i = 1 to Lv.items.count do
(
if Lv.items.item[i].Checked == true do
(
print i
)
)
destroyDialog DE_Dl3
)
)
createDialog DE_DL3

)


I want pressed del button then script delete the file selected

http://ni0.upanh.com/b3.s13.d3/b822b768e30902d2255730127a27edfe_41127100.untitled1.jpg

Who can help me ?
thanks !

DaveWortley
02-20-2012, 01:04 PM
for i = lv.selecteditems.count to 1 by -1 do
(
--delete the max file..
deleteFile a.tag
lv.Items.Remove(lv.selecteditems.item[i-1])
)

Something like this?....

edit: Although I've used this multiselect and without checkboxes so might need to be different with checkboxes...

baotd86
02-20-2012, 01:27 PM
can you make a script access the files selected ?

baotd86
02-20-2012, 01:49 PM
when we click on the botton below, the script will process the selected files. for example: " check keys on those one"

CGTalk Moderation
02-20-2012, 01:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.