更新时间:2023-11-13 11:38:40
根据由AVIDeveloper提供的链接评论。
Based on the comment in the link provided by AVIDeveloper.
虽然ShowFocusCues本身没有工作,WM_CHANGEUISTATE
该MSDN页面上列出导致我正确的答案。通过发送一个
与UISF_HIDEFOCUS WM_CHANGEUISTATE消息,我能够摆脱
焦点矩形。 - Telanor 4月22日在'10 17时11分
While the ShowFocusCues itself didn't work, the WM_CHANGEUISTATE listed on that MSDN page led me to the right answer. By sending a WM_CHANGEUISTATE message with UISF_HIDEFOCUS I was able to get rid of the focus rectangle. – Telanor Apr 22 '10 at 17:11
我试图找到有关此消息的一些信息和eventualy看到了这个帖子:http://cboard.cprogramming.com/csharp-programming/128345-listview-remove-focuscues.html#post958690
I tried to find some information about this messages and eventualy saw this post: http://cboard.cprogramming.com/csharp-programming/128345-listview-remove-focuscues.html#post958690
所以,我们需要发送WM_CHANGEUISTATE消息到ListView在构造
So, we need to send the WM_CHANGEUISTATE message to the ListView in the constructor
SendMessage(Handle, 0x127, 0x10001, 0);
和我们只打算重写OnSelectedIndexChanged和的OnEnter事件。
And we are only going to override the OnSelectedIndexChanged and OnEnter events.
protected override void OnSelectedIndexChanged(EventArgs e)
{
base.OnSelectedIndexChanged(e);
SendMessage(Handle, 0x127, 0x10001, 0);
}
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
SendMessage(Handle, 0x127, 0x10001, 0);
}
无覆盖的OnEnter事件,同样的黑色虚线选择矩形的时候会在ListView获得焦点出现。
Without overriding the OnEnter event, the same black dotted selection rectangle will appear when the ListView gets the focus.
我试图解释尽我所能,因为我不是一个英语流利的和我要等待,如果有人接受我之前更好的答案。
I tried to explain the best I could since I'm not a fluent English speaker and I'm going to wait if someone has a better answer before accepting mine.