C# listview 大图标选中显示问题

塔克茜丝 2020-01-09 11:43:36
用listview做了个头像选中菜单,发现选中的后,蓝色底很难看,有什么办法改掉么?
需要重写什么函数?

改成后面背景色变掉的。
...全文
236 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
塔克茜丝 2020-01-11
  • 打赏
  • 举报
回复
有高手回复么?
塔克茜丝 2020-01-09
  • 打赏
  • 举报
回复
引用 1 楼 爱吃肉的羊呐 的回复:
不太清楚你的问题是什么!图片底色有问题?

就是说选中了,这个图片就被蓝色挡住了,而不是类似控件选中,边框泛蓝,能改掉么?
assky124 2020-01-09
  • 打赏
  • 举报
回复
可以用系统的样式

/******************************************
-- Author       : Coder.Yan
-- Create date  : 2012-09-25 09:03:33
-- CopyRight    : HZST (C) 2012
-- Description  : 
 ******************************************/
    internal class ShapeLibView:ListView
    {
        [DllImport("uxtheme.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
        private static extern int SetWindowTheme(IntPtr hWnd, string appName, string partList);
        [DllImport("User32.dll")]
        private static extern int SendMessage(IntPtr Handle, int wMsg, int wParam, int lParam);
        const int LVM_FIRST = 0x1000;
        const int LVM_SETICONSPACING = LVM_FIRST + 53;



        public ShapeLibView()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this._contextMenu = new ContextMenuStrip(components);
            this._images = new System.Windows.Forms.ImageList(this.components);

            this.SuspendLayout();

            this.LargeImageList = _images;
            this.SmallImageList = _images;

            // 
            // _images
            // 
            this._images.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
            this._images.ImageSize = new System.Drawing.Size(48, 48);
            this._images.TransparentColor = System.Drawing.Color.Transparent;

            this.ResumeLayout();
        }

        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);    
            SetWindowTheme(this.Handle, "explorer", null);
            SendMessage(this.Handle, LVM_SETICONSPACING, 0, 70 * 65536 + 50);
        }
    }
爱吃肉的羊呐 2020-01-09
  • 打赏
  • 举报
回复
不太清楚你的问题是什么!图片底色有问题?

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧