gpt4 book ai didi

c# - 如何删除 ListViewItem 上的选择边框

转载 作者:太空狗 更新时间:2023-10-29 17:35:29 26 4
gpt4 key购买 nike

我正在使用 SetWindowTheme 和 SendMessage 使 .net ListView 看起来像 vista 样式的 ListView ,但 .net 控件在所选项目周围仍然有一个虚线选择边框:

listview

浏览器 ListView 中的选定项目周围没有边框。我怎样才能删除它?

Windows 资源管理器:

windows explorer

编辑:解决方案:

public static int MAKELONG(int wLow, int wHigh)
{
int low = (int)LOWORD(wLow);
short high = LOWORD(wHigh);
int product = 0x00010000 * (int)high;
int makeLong = (int)(low | product);
return makeLong;
}

SendMessage(olv.Handle, WM_CHANGEUISTATE, Program.MAKELONG(UIS_SET, UISF_HIDEFOCUS), 0);

最佳答案

Telanors 的解决方案对我很有效。这是一个稍微更独立的版本。

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public class MyListView : ListView
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

private const int WM_CHANGEUISTATE = 0x127;
private const int UIS_SET = 1;
private const int UISF_HIDEFOCUS = 0x1;

public MyListView()
{
this.View = View.Details;
this.FullRowSelect = true;

// removes the ugly dotted line around focused item
SendMessage(this.Handle, WM_CHANGEUISTATE, MakeLong(UIS_SET, UISF_HIDEFOCUS), 0);
}

private int MakeLong(int wLow, int wHigh)
{
int low = (int)IntLoWord(wLow);
short high = IntLoWord(wHigh);
int product = 0x10000 * (int)high;
int mkLong = (int)(low | product);
return mkLong;
}

private short IntLoWord(int word)
{
return (short)(word & short.MaxValue);
}
}

关于c# - 如何删除 ListViewItem 上的选择边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2691726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com