/// <summary> /// Associates a SysImageList with a TreeView control /// </summary> /// <param name="treeView">TreeView control to associated ImageList with</param> /// <param name="sysImageList">System Image List to associate</param> /// <param name="forStateImages">Whether to add ImageList as StateImageList</param> public static void SetTreeViewImageList( System.Windows.Forms.TreeView treeView, SystemImageList sysImageList, bool forStateImages ) { System.IntPtr wParam = (System.IntPtr)TVSIL_NORMAL; if (forStateImages) { wParam = (System.IntPtr)TVSIL_STATE; } SendMessage( treeView.Handle, TVM_SETIMAGELIST, wParam, sysImageList.Handle); }
/// <summary> /// Associates a SysImageList with a ListView control /// </summary> /// <param name="listView">ListView control to associate ImageList with</param> /// <param name="sysImageList">System Image List to associate</param> /// <param name="forStateImages">Whether to add ImageList as StateImageList</param> public static void SetListViewImageList( System.Windows.Forms.ListView listView, SystemImageList sysImageList, bool forStateImages ) { System.IntPtr wParam = (System.IntPtr)LVSIL_NORMAL; if (sysImageList.ImageListSize == SystemImageListSize.SmallIcons) { wParam = (System.IntPtr)LVSIL_SMALL; } if (forStateImages) { wParam = (System.IntPtr)LVSIL_STATE; } SendMessage( listView.Handle, LVM_SETIMAGELIST, wParam, sysImageList.Handle); }
/// <summary> /// Extract the icon for the file type (Extension) /// </summary> protected virtual void SetIcon(TreeViewFolderBrowser treeView, TreeNodePath node) { // create on demand if (_systemImageList == null) { // Shell32 ImageList _systemImageList = new SystemImageList(SystemImageListSize.SmallIcons); SystemImageListHelper.SetTreeViewImageList(treeView, _systemImageList, false); } node.ImageIndex = _systemImageList.IconIndex("", true); node.SelectedImageIndex = node.ImageIndex; }
/// <summary> /// Associates a SysImageList with a TreeView control /// </summary> /// <param name = "treeView">TreeView control to associated ImageList with</param> /// <param name = "sysImageList">System Image List to associate</param> /// <param name = "forStateImages">Whether to add ImageList as StateImageList</param> public static void SetTreeViewImageList( TreeView treeView, SystemImageList sysImageList, bool forStateImages ) { IntPtr wParam = (IntPtr)TVSIL_NORMAL; if (forStateImages) { wParam = (IntPtr)TVSIL_STATE; } SendMessage( treeView.Handle, TVM_SETIMAGELIST, wParam, sysImageList.Handle); }
/// <summary> /// Associates a SysImageList with a ListView control /// </summary> /// <param name = "listView">ListView control to associate ImageList with</param> /// <param name = "sysImageList">System Image List to associate</param> /// <param name = "forStateImages">Whether to add ImageList as StateImageList</param> public static void SetListViewImageList( ListView listView, SystemImageList sysImageList, bool forStateImages ) { IntPtr wParam = (IntPtr)LVSIL_NORMAL; if (sysImageList.ImageListSize == SystemImageListSize.SmallIcons) { wParam = (IntPtr)LVSIL_SMALL; } if (forStateImages) { wParam = (IntPtr)LVSIL_STATE; } SendMessage( listView.Handle, LVM_SETIMAGELIST, wParam, sysImageList.Handle); }