Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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??

Dream as if you'll live forever, live as if you'll die today
  • Leaders
Posted


   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.

Posted

Thanks a million..

Although the cursor still shows for a fraction of a second, it is the best i have got.

 

Cheers,

Dream as if you'll live forever, live as if you'll die today
Posted

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??

Dream as if you'll live forever, live as if you'll die today
Posted
Yes, that's what i thought but for some reason the Enter event was not raised !!!!!
Dream as if you'll live forever, live as if you'll die today
Posted

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.:)

Dream as if you'll live forever, live as if you'll die today

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...