Пример #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
            )
        {
            var wParam = (IntPtr)TvsilNormal;

            if (forStateImages)
            {
                wParam = (IntPtr)TvsilState;
            }
            SendMessage(
                treeView.Handle,
                TvmSetimagelist,
                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
            )
        {
            var wParam = (IntPtr)LvsilNormal;

            if (sysImageList.ImageListSize == SysImageListSize.SmallIcons)
            {
                wParam = (IntPtr)LvsilSmall;
            }
            if (forStateImages)
            {
                wParam = (IntPtr)LvsilState;
            }
            SendMessage(
                listView.Handle,
                LvmSetimagelist,
                wParam,
                sysImageList.Handle);
        }