加载列表视图项 [英] Load list-view items
本文介绍了加载列表视图项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图像使用ListView控件一样制作桌面。
我无法使用此代码来加载ListView上的项目。
这是
Dim myIcon As System.Drawing.Icon
myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon)
这是烦恼,我无法让它工作。
Dim MyFiles As String
Dim sr2 As StreamReader
sr2 =新StreamReader(files.txt)
MyFiles = sr2.ReadToEnd()
Dim hImgSmall作为IntPtr
Dim hImgLarge As IntPtr
Dim shinfo As SHFILEINFO
shinfo = New SHFILEINFO()
ListView1.SmallImageList = ImageList1
ListView1.LargeImageList = ImageList1
shinfo.szDisplayName = New String(Chr(0),260)
shinfo.szTypeName = New String(Chr(0),80)
hImgSmall = SHGetFileInfo(MyFiles,0,shinfo, Marshal.SizeOf(shinfo),_
SHGFI_ICON或SHGFI_SMALLICON)
Dim myIcon As System.Drawing.Icon
myIcon = System.Drawing.Icon.FromHandle( shinfo.hIcon)
ImageList1.Images.Add(myIcon)
ListView1.Items.Add(MyFiles,nIndex)
nIndex = nIndex + 1
我尝试过:
我尝试了不同的文件路径
解决方案
您只需要适当地设置ListView的View属性。
访问这里,了解您的选择。
Hi,
Im trying to make like a Desktop with the ListView control.
I can't get this code to work which is loading the items on the ListView.
It's the
Dim myIcon As System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon)
That is bugging and i can't get this to work.
Dim MyFiles As String Dim sr2 As StreamReader sr2 = New StreamReader("files.txt") MyFiles = sr2.ReadToEnd() Dim hImgSmall As IntPtr Dim hImgLarge As IntPtr Dim shinfo As SHFILEINFO shinfo = New SHFILEINFO() ListView1.SmallImageList = ImageList1 ListView1.LargeImageList = ImageList1 shinfo.szDisplayName = New String(Chr(0), 260) shinfo.szTypeName = New String(Chr(0), 80) hImgSmall = SHGetFileInfo(MyFiles, 0, shinfo, Marshal.SizeOf(shinfo), _ SHGFI_ICON Or SHGFI_SMALLICON) Dim myIcon As System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon) ImageList1.Images.Add(myIcon) ListView1.Items.Add(MyFiles, nIndex) nIndex = nIndex + 1
What I have tried:
I have tried different file paths
解决方案
You just need to set the "View" property of your ListView appropriately.
Go HERE to see what your options are.
这篇关于加载列表视图项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文