コード例 #1
0
        /// <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,
            SysImageList sysImageList,
            bool forStateImages
            )
        {
            IntPtr wParam = (IntPtr)TVSIL_NORMAL;

            if (forStateImages)
            {
                wParam = (IntPtr)TVSIL_STATE;
            }
            NativeMethods.SendMessage(
                treeView.Handle,
                TVM_SETIMAGELIST,
                wParam,
                sysImageList.Handle);
        }
コード例 #2
0
        /// <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,
            SysImageList sysImageList,
            bool forStateImages
            )
        {
            IntPtr wParam = (IntPtr)LVSIL_NORMAL;

            if (sysImageList.ImageListSize == SysImageListSize.smallIcons)
            {
                wParam = (IntPtr)LVSIL_SMALL;
            }
            if (forStateImages)
            {
                wParam = (IntPtr)LVSIL_STATE;
            }
            NativeMethods.SendMessage(
                listView.Handle,
                LVM_SETIMAGELIST,
                wParam,
                sysImageList.Handle);
        }