0
我知道CF中缺少“HideSelection”属性。 但我仍然需要处理的情况下,当一个项目被选中时,即使控件失去焦点,它仍然被选中(灰色)。CF TreeView - 控件失去焦点时的选定项目
我已经尝试使用这种代码的和平,但没有成功。我在GetFocus()方法中遇到异常,我不知道我做错了什么。
任何帮助非常感谢!
[DllImport("User32.dll")]
static extern IntPtr GetFocus();
[DllImport("User32.dll")]
static extern Int32 GetWindowLong(IntPtr hwnd, Int32 integer1);
[DllImport("User32.dll")]
static extern IntPtr SetWindowLong(IntPtr hwnd, Int32 integer1, int integer2);
private bool doneOnce;
protected override void OnGotFocus(System.EventArgs e)
{
base.OnGotFocus(e);
if (this.itemsTreeView != null)
{
this.itemsTreeView.Focus();
if (doneOnce == false)
{
doneOnce = true;
IntPtr hWnd = GetFocus();
Int32 lS = GetWindowLong(hWnd, -16);
lS = lS | 0x20;
SetWindowLong(hWnd, -16, lS);
}
}
}
我已经把这段代码在我的“背后的代码”视图保存TreeView控件。
thanx很多!奇迹般有效。你是男人:) – no9 2010-05-18 11:01:56