关于ListView的拖拽问题,高手进,在线等!
拖拽ListViewItem的时候,希望能出现被拖拽项的图标,请问该怎么做?
------解决方案--------------------public struct SHFILEINFO
{
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
public string szTypeName;
};
.....
.....
IntPtr hImagSmall, hImagLarge;
hImagSmall = Win32.SHGetFileInfo(SFile, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo)
, Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON); imageListsmall.Images.Add(
System.Drawing.Icon.FromHandle(shinfo.hIcon));
hImagLarge = Win32.SHGetFileInfo(SFile, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo)
, Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON); imageListlarge.Images.Add(
System.Drawing.Icon.FromHandle(shinfo.hIcon));
------解决方案--------------------提供一个思路:
创建图片,跟随鼠标!!
------解决方案--------------------楼主可以在MouseDown事件里调用ListView的
public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects)
这个方法,然后在DragEnter,DragOver等事件里处理这个拖拽就行了.
------解决方案--------------------研究一下
------解决方案--------------------mark
------解决方案--------------------做一个小的button再贴上icon可以吗