Mehyar Posted July 1, 2003 Posted July 1, 2003 Hi guys, I have been trying to edit my TextBox such that when it is readonly and the cursor doesnot appear in it when it receives focus. I tried to inherit the texbox and override the OnClick, OnMouseDOwn, OnEnter and Returned without calling the BaseClass if it is readonly. Everything works and the base class is not called but the text box still receives focus any ideas?? Quote Dream as if you'll live forever, live as if you'll die today
Leaders dynamic_sysop Posted July 1, 2003 Leaders Posted July 1, 2003 Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown Label1.Focus() '/// move focus to another control to prevent cursor showing End Sub Private Sub TextBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseUp Label1.Focus() End Sub that stops the cursor showing in the textbox , also it prevents it being edited even if readonly is false. Quote
Mehyar Posted July 1, 2003 Author Posted July 1, 2003 Thanks a million.. Although the cursor still shows for a fraction of a second, it is the best i have got. Cheers, Quote Dream as if you'll live forever, live as if you'll die today
Mehyar Posted July 1, 2003 Author Posted July 1, 2003 But still... Another problem arises , what if the user gets focus on the textbox by using the Tab Key, in this case the events ofcourse are not raised, i though of the Enter Event but for my surprise it was not raised !!!!! Any suggestions?? Quote Dream as if you'll live forever, live as if you'll die today
Leaders dynamic_sysop Posted July 1, 2003 Leaders Posted July 1, 2003 Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter Label1.Focus() '/// now you wont see a cursor. End Sub :) Quote
Mehyar Posted July 1, 2003 Author Posted July 1, 2003 Yes, that's what i thought but for some reason the Enter event was not raised !!!!! Quote Dream as if you'll live forever, live as if you'll die today
Mehyar Posted July 1, 2003 Author Posted July 1, 2003 Great, thx dynamic_sysop. The enter event was not raised since the text box i had was read only so i set it to readonly = false and it worked perfectly .... Is this sort of a bug that Microsft developers didnot see, I mean the Readonly textbox shows the focus but it doesnot call Enter ???:confused: Anyways thank you for your help, and may your twins come in best health.:) Quote Dream as if you'll live forever, live as if you'll die today
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.