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