日期:2014-05-20  浏览次数:20914 次

winfrom 光标问题


启动窗体。  怎么让光标定位在最上面的隐藏的textBox。

鼠标点击除textBox以为的地方 让光标失去焦点。
或者让他放入隐藏的textBox中。。
textbox winfrom

------解决方案--------------------
最上面的隐藏的textBox

隐藏了还怎么获得焦点
------解决方案--------------------
隐藏光标
 
       
[DllImport("user32.dll", EntryPoint = "HideCaret")]
public static extern bool HideCaret(IntPtr hWnd);

textBox1.GotFocus += new EventHandler(textBox_GotFocus);
textBox1.MouseDown += new MouseEventHandler(textBox_MouseDown);
textBox2.GotFocus += new EventHandler(textBox_GotFocus);
textBox2.MouseDown += new MouseEventHandler(textBox_MouseDown);

void textBox_GotFocus(object sender, EventArgs e)
        {
            HideCaret(((TextBox)(sender)).Handle);
        }

  private void textBox_MouseDown(object sender, MouseEventArgs e)
        {
            HideCaret(((TextBox)(sender)).Handle);
        }