EverZen
03-18-2008, 05:46 PM
Hi guys,
I ma majorly use to this Dot Net stuff, but I am determined to crack it. I am looking to get icon images to replace the checkbox tick box (A little like the layermanager), so I can include my own custom icons for different things.
I have no idea how to get the images in the ListView Checkboxes though.... This is what Ive done so far... this is just random snippets of code...
--Create a List View
dotNetControl lv "System.Windows.Forms.ListView" width:290 height:160 pos:[20,20]
local lvItems=for x=1 to 4 collect "Item "+x as string -- Some listview Items
lv.View = (dotNetClass "System.Windows.Forms.View").Details
lv.fullRowSelect = true -- When item is clicked, all columns in that item are selected
lv.checkboxes = true -- Add checkboxes (to which im trying to add the images)
lv.Columns.add "Col1" 80 -- Add some nice columns
lv.Columns.add "Col2" 80
lv.Columns.add "Col3" 80
theRange = #()
for x=1 to lvItems.count do ( li = dotNetObject "System.Windows.Forms.ListViewItem" lvItems[x]; append theRange li )
lv.Items.AddRange theRange -- add in all the items
--From here I assume the ListViewItems need the images provided, which I thought would be an image list... this is where the real confusions starts....
--Create an Image add it to an image list...
CheckImage = dotNetClass "System.Drawing.Image"
CheckImage.FromFile "C:\SampleImage.jpg"
smallImageList = dotnetObject "System.Windows.Forms.ImageList"
smallImageList.Images.Add(CheckImage.FromFile "C:\SampleImage.jpg")
-This has successfully created the image list and added the image... but I cannot get this to the listviewitem. I tried setting it to the ImageList property, but that is read only!
How can I set this image list to be recognised by the checkboxes in the listview, so that the images are displayed? And then how can I change the image depending on the state?
Really sorry to ask, but any pointers would be ace, since I am just starting out, and to be honest am really struggling!
Thanks for your time everyone :)
Rich
I ma majorly use to this Dot Net stuff, but I am determined to crack it. I am looking to get icon images to replace the checkbox tick box (A little like the layermanager), so I can include my own custom icons for different things.
I have no idea how to get the images in the ListView Checkboxes though.... This is what Ive done so far... this is just random snippets of code...
--Create a List View
dotNetControl lv "System.Windows.Forms.ListView" width:290 height:160 pos:[20,20]
local lvItems=for x=1 to 4 collect "Item "+x as string -- Some listview Items
lv.View = (dotNetClass "System.Windows.Forms.View").Details
lv.fullRowSelect = true -- When item is clicked, all columns in that item are selected
lv.checkboxes = true -- Add checkboxes (to which im trying to add the images)
lv.Columns.add "Col1" 80 -- Add some nice columns
lv.Columns.add "Col2" 80
lv.Columns.add "Col3" 80
theRange = #()
for x=1 to lvItems.count do ( li = dotNetObject "System.Windows.Forms.ListViewItem" lvItems[x]; append theRange li )
lv.Items.AddRange theRange -- add in all the items
--From here I assume the ListViewItems need the images provided, which I thought would be an image list... this is where the real confusions starts....
--Create an Image add it to an image list...
CheckImage = dotNetClass "System.Drawing.Image"
CheckImage.FromFile "C:\SampleImage.jpg"
smallImageList = dotnetObject "System.Windows.Forms.ImageList"
smallImageList.Images.Add(CheckImage.FromFile "C:\SampleImage.jpg")
-This has successfully created the image list and added the image... but I cannot get this to the listviewitem. I tried setting it to the ImageList property, but that is read only!
How can I set this image list to be recognised by the checkboxes in the listview, so that the images are displayed? And then how can I change the image depending on the state?
Really sorry to ask, but any pointers would be ace, since I am just starting out, and to be honest am really struggling!
Thanks for your time everyone :)
Rich
