|
-
Oct 27th, 2001, 01:00 AM
#1
Thread Starter
PowerPoster
What the f**k is with the focus
I am using the simpleeeeeeeeest thing....actually, I am trying to set the focus of any object but it is giving me an error message saying "invalid procedure call".
For example:
Form1.SetFocus
or
ListView1.SetFocus
It gives me that error message for all of the above calls.
-
Oct 27th, 2001, 01:05 AM
#2
PowerPoster
-
Oct 27th, 2001, 01:07 AM
#3
Frenzied Member
i tried putting form1.setfocus in form_load and it gave me the same error, try putting it in a procedure that it gurranteed to make sure form1 doesn't have the focus or is visible.
-
Oct 27th, 2001, 01:08 AM
#4
PowerPoster
If you put it in the Form_Activate sub, it shouldn't give you an error. You have to make sure the form is visible before you set focus to it.
-
Oct 27th, 2001, 01:26 AM
#5
Thread Starter
PowerPoster
I am putting this under the event of "ItemClick" of a listview. So, whenever the user clicks on an item in the listview, it gives the focus to a textbox on the form.
-
Oct 27th, 2001, 06:43 AM
#6
A Form is NOT going to receive focus if there are visible and enabled controls on it. Thats why you are getting the "Invalid Procedure Call" for the Form.SetFocus
On the other hand, I don't see why you are getting that for the ListView control.
-
Oct 27th, 2001, 11:21 AM
#7
You cannot set focus to the controls in the Load() event, because they have not been made visible yet. Put the code in the Activate() event, or commandbutton instead.
-
Oct 27th, 2001, 11:26 AM
#8
Member
Originally posted by Megatron
You cannot set focus to the controls in the Load() event, because they have not been made visible yet. Put the code in the Activate() event, or commandbutton instead.
Actually, you can:
VB Code:
Private Sub Form_Load()
[b]Me.Show
DoEvents[/b]
Command1.SetFocus
End Sub
-
Oct 27th, 2001, 11:51 AM
#9
1) You don't need DoEvents there
2) You are deliberately showing the form though. Try the following code, and you'll get an error.
VB Code:
Private Sub Form_Load()
Command1.SetFocus
End Sub
-
Oct 27th, 2001, 01:13 PM
#10
Thread Starter
PowerPoster
Originally posted by abdul
I am putting this under the event of "ItemClick" of a listview. So, whenever the user clicks on an item in the listview, it gives the focus to a textbox on the form.
-
Oct 27th, 2001, 01:38 PM
#11
PowerPoster
Originally posted by Megatron
You cannot set focus to the controls in the Load() event, because they have not been made visible yet. Put the code in the Activate() event, or commandbutton instead.
Did I mention this like 3 posts before you posted that?
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
|