Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET General

Post new topic   Reply to topic
ActiveControl.Name
View previous topic :: View next topic  
Author Message
jeaniedave
Newbie


Joined: 23 Oct 2003
Posts: 2

PostPosted: Oct 23rd, 2003 12:18 AM    Post subject: ActiveControl.Name Reply with quote

I am entering data in a Textbox, and then using the tab to change focus to a second Textbox. Both textboxes are defined in a Handles statement on a Textbox_Validating event.

Private Sub TextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating, TextBox2.Validating

'ActiveControl.Name has TextBox2 when
' tabbing from Textbox1 to Textbox2
End Sub

I wanted to use a generic routine for simplicity. But in the validating event, I see that the ActiveControl.Name is the name of the second textbox, not the first textbox that I expected since it is the value in the first textbox that I am trying to validate.

Further testing shows that the Enter and GotFocus events maintain the ActiveControl.Name value of the first textbox. But
the Leave, Validating, Validated, and LostFocus events change
and have the value of the second textbox.

Is there some other generic way to tell in the Validating event which control is being validated?

Thanks,
Dave
Back to top
View user's profile Send private message
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Oct 23rd, 2003 05:19 PM    Post subject: Reply with quote

Is this in .Net?
_________________
No one is completely useless. They can at least be an example of what to avoid.
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
jeaniedave
Newbie


Joined: 23 Oct 2003
Posts: 2

PostPosted: Oct 23rd, 2003 09:24 PM    Post subject: Reply with quote

Yes it is.

And I found the technique. I have to cast the sender object to a textbox.

Dim t as TextBox
t = Ctype(sender,Textbox)

now, t.name contains the name of the control passed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic