-
August 6th, 2009, 02:48 AM
#1
How To Get Rid of SetFocus on TextBoxes
Hi VB gurus,
Need some help here...Doing an application with VB6 that uses textboxes and click actions...How do I get rid of the SetFocus which appears in the textboxes during run-time. TQ.
-
August 6th, 2009, 03:30 AM
#2
Re: How To Get Rid of SetFocus on TextBoxes
Set the TabStop property of the TextBox to False, in Design Time
By the way, welcome to the Forums!
-
August 6th, 2009, 05:28 AM
#3
Re: How To Get Rid of SetFocus on TextBoxes
You can also achieve this by keeping all the text boxes in a frame and disable the frame during form load or design.
Once form is active and when required you can enable the Frame. Still if you click on textbox cursor enters the textbox and will get the focus. If you are avoiding the user to make changes in the textboxes but you want them to click, you can use locked property of textbox to make readonly.
Last edited by ComITSolutions; August 6th, 2009 at 05:30 AM.
Encourage the efforts of fellow members by rating
Lets not Spoon Feed and create pool of lazy programmers
- ComIT Solutions
-
August 6th, 2009, 09:37 PM
#4
Re: How To Get Rid of SetFocus on TextBoxes
Originally Posted by HanneSThEGreaT
Set the TabStop property of the TextBox to False, in Design Time
By the way, welcome to the Forums!
Thanks for the tips However, cursor still appears in TextBox during runtime.
-
August 6th, 2009, 09:45 PM
#5
Re: How To Get Rid of SetFocus on TextBoxes
Originally Posted by ComITSolutions
You can also achieve this by keeping all the text boxes in a frame and disable the frame during form load or design.
Once form is active and when required you can enable the Frame. Still if you click on textbox cursor enters the textbox and will get the focus. If you are avoiding the user to make changes in the textboxes but you want them to click, you can use locked property of textbox to make readonly.
Thanks for the info But the cursor still enters the textbox. Any possible way to hide the focus?
-
August 6th, 2009, 10:23 PM
#6
Re: How To Get Rid of SetFocus on TextBoxes
In the SetFocus() event, just move the cursor to the next valid cursor. Otherwise, if the .TabStop is set to FALSE, the user will tab by it.
-
August 7th, 2009, 12:29 AM
#7
Re: How To Get Rid of SetFocus on TextBoxes
Originally Posted by VirtualBaby
Thanks for the info But the cursor still enters the textbox. Any possible way to hide the focus?
In post #3 I have mentioned that if mouse is clicked on textbox focus will go the text box, read the post clearly.
1) If Foucus is not needed why are using Textbox? you can use labels and fool the user by Setting backcolor property to &H8000000E (white) and BorderStyle Property to 1 that is fixed single.
You can code for lable's click event.
2) If you still persists using textbox and it should not be focused then make its enabled property false, but you will not be able to raise mouse click event.
3) What are you trying to do in your program? If you explain in detail, there are many gurus in this forum will guide you in the right direction.
Encourage the efforts of fellow members by rating
Lets not Spoon Feed and create pool of lazy programmers
- ComIT Solutions
-
August 7th, 2009, 01:11 AM
#8
Re: How To Get Rid of SetFocus on TextBoxes
You could also use the TextBox's GotFocus event to redirect the focus to another control.
This whole concept of yours basically defeats the purpose of having a TextBox there in the first place. Why do you want a textBox which is "unfocusable" ¿
-
August 7th, 2009, 04:36 AM
#9
Re: How To Get Rid of SetFocus on TextBoxes
Originally Posted by HanneSThEGreaT
You could also use the TextBox's GotFocus event to redirect the focus to another control.
This whole concept of yours basically defeats the purpose of having a TextBox there in the first place. Why do you want a textBox which is "unfocusable" ¿
I feel the same way !
Encourage the efforts of fellow members by rating
Lets not Spoon Feed and create pool of lazy programmers
- ComIT Solutions
-
August 7th, 2009, 09:45 AM
#10
Re: How To Get Rid of SetFocus on TextBoxes
One might want to use a textbox because of its abilty to have scrollbars and multiline and wordwrap.
I had a similar situation once, so what I did was:
I put a dummy textbox named txtTrap outside the visible range of the form.
Then in the _GotFocus() event of the TextBox where I did not want a focus I put:
txtTrap.SetFocus()
So whenever this window gets the focus it passes it on to an invisible field.
-
August 7th, 2009, 03:57 PM
#11
Re: How To Get Rid of SetFocus on TextBoxes
Hello,
Assuming Text1 is not the only control on the form, this will work whatever would be the Tabstop and the tabindex properties of text1 :
Code:
Private Sub Text1_GotFocus()
Text1.Enabled = False
End Sub
Private Sub Text1_LostFocus()
Text1.Enabled = True
End Sub
And so, the scrollbars would work too...
-
August 9th, 2009, 08:15 AM
#12
Re: How To Get Rid of SetFocus on TextBoxes
Originally Posted by WoF
One might want to use a textbox because of its abilty to have scrollbars and multiline and wordwrap.
I had a similar situation once, so what I did was:
I put a dummy textbox named txtTrap outside the visible range of the form.
Then in the _GotFocus() event of the TextBox where I did not want a focus I put:
txtTrap.SetFocus()
So whenever this window gets the focus it passes it on to an invisible field.
Good One WoF!!
Encourage the efforts of fellow members by rating
Lets not Spoon Feed and create pool of lazy programmers
- ComIT Solutions
-
August 13th, 2009, 08:00 PM
#13
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|