Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling multiple objects

Status
Not open for further replies.

arrian

Programmer
Nov 11, 2003
93
CA
I have a program with a hand made grid using text boxes. I have an event that needs to fire on the GotFocus for the boxes. All the boxes in one line will have the same trigger activated when I call them. This is the code I'm currently using:

Private Sub txtDNum1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDNum1.GotFocus, txtClient1.GotFocus, txtDesc1.GotFocus, txtTitleA1.GotFocus, txtTitleB1.GotFocus
intGridLocation = 0
If intGridLocation <> intLastGrid Then
SaveRows(intLastGrid)
End If
End Sub

The problem I'm having is that it's not handling anything other than txtDNum1.GotFocus. Is there something I'm doing wrong with this that could be causing it? Please let me know!
 
It should be working. If you put a breakpoint on
Code:
 intGridLocation = 0
this will be confirmed.

Are you sure that the problem isn't the line...
Code:
If intGridLocation <> intLastGrid Then

or perhaps you're doing something in code to prevent the textboxes receiving focus (eg disabled)
 
I've put a breakpoint, and it doesn't go in when anything other than txtDNum1 gets focus. The code inside works properly, but the event doesn't fire on when txtClient1 gets focus, etc...
 
how is the user passing focus? (tab,mouse click)...try each method and see if it's the same behaviour.

this may be related to issues with other controls getting the focus and not passing it on due to the order of events (thread796-1073921).

Also check all the events for controls and for the form to ensure that there isn't a control stealing focus before it gets to the textbox.

 
If Focus is causing these problems, you could try utilising the Enter event.


Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
I just tried it with both mouse clicks and tabbing, and neither works. It only seems to work if you leave or enter the txtDNum boxes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top