Page 1 of 1
Listview Save
Posted: Tue Jun 07, 2011 6:02 pm
by M1z23R
Ok, so i am trying to make a "short cut" program...
You right click the Listview on my form and select from context menu "Add file"
I know how to add item with icon and text, and i set "tool tip text" as "filename", and "text" to "safefilename" ...
I add icon to image list too
How can i save all that, and reload it ?

Re: Listview Save
Posted: Tue Jun 07, 2011 6:18 pm
by Napster1488
U wonna Save all the Items u added in Listview ?!
Re: Listview Save
Posted: Tue Jun 07, 2011 6:44 pm
by M1z23R
yes, but i also want to save images from image list, so i can use them too :/
Re: Listview Save
Posted: Tue Jun 07, 2011 7:06 pm
by Napster1488
M1z23R wrote:yes, but i also want to save images from image list, so i can use them too :/
Please Post your Code here how do u load Images etc.
After that i can make Code for you to Save Items from Listview.
Re: Listview Save
Posted: Tue Jun 07, 2011 7:18 pm
by M1z23R
Code: Select all On Error Resume Next
Dim hImgSmall As IntPtr
Dim hImgLarge As IntPtr
Dim shinfo As SHFILEINFO
shinfo = New SHFILEINFO()
Dim opn As OpenFileDialog
opn = New OpenFileDialog()
opn.InitialDirectory = "c:\temp\"
opn.Filter = "All files (*.*)|*.*"
opn.FilterIndex = 2
opn.RestoreDirectory = True
ListView1.SmallImageList = ImageList1
ListView1.LargeImageList = ImageList1
shinfo.szDisplayName = New String(Chr(0), 260)
shinfo.szTypeName = New String(Chr(0), 80)
If (opn.ShowDialog() = DialogResult.OK) Then
hImgLarge = SHGetFileInfo(opn.FileName, 0, shinfo, Marshal.SizeOf(shinfo), _
SHGFI_ICON Or SHGFI_LARGEICON)
Dim myIcon As System.Drawing.Icon
myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon)
ImageList1.Images.Add(myIcon) 'Add icon to imageList.
Dim lvitm As New ListViewItem
lvitm.Text = opn.SafeFileName
lvitm.ToolTipText = opn.FileName
ListView1.Items.Add(lvitm)
lvitm.ImageIndex = ImageList1.Images.Count - 1
End If