我有這個簡單的代碼,當用戶離開TextBox控件,其中,TreeView控件得到集中:C#的TreeView SetFocus的射擊離開事件兩次
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.treeView1.Nodes.Add("A");
this.treeView1.Nodes[0].Nodes.Add("A.A");
this.treeView1.Nodes.Add("B");
this.treeView1.Nodes[0].Nodes.Add("B.A");
}
private void textBox1_Leave(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Leave..");
this.treeView1.Focus();
}
}
如果我們執行這個代碼Leave事件被觸發兩次:
離開..
離開..
但是,如果我們將焦點設置其他的控制,只有一個離開事件。
這是TreeView的問題嗎?你知道任何解決方法嗎?我們應該向微軟報告嗎?
感謝, RG
我已經檢查過,並且該事件只安裝一次。 – RGil 2010-11-10 15:35:34