Is there a way to write code behind say 1 gotfocus of a textbox and have it affect all textboxs? If I have 20 textboxes on screen I dont want to have to put code in 20 places. Just 1 place. Is this possible?
For example, if I want to change the background color of all the textboxes that have focus, without writing in the gotfocus of every textbox.
Thanks in advance..
Sure, just list all the textboxes in the event's Handles clause:
A cleaner approach is to create a new class which inherits from TextBox and which overrides the OnGotFocus method with the desired code. Then, instead of using the standard TextBox control on your form, use the inherited class: http://forums.devx.com/showpost.php?...65&postcount=2
Private Sub TextBox_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox1.GotFocus, TextBox2.GotFocus ' , etc.
Last edited by Phil Weber; 02-23-2007 at 06:24 PM.
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
geez that would have saved me some time...
That's what I was doing but I had my sub doing the wrong thing so it wasn't working. I figured it out and works fine.
Thank you for your help.
By ASP learner in forum ASP.NET
Last Post: 10-08-2002, 08:17 PM
Last Post: 03-28-2002, 08:14 AM
By melvin ng in forum VB Classic
Last Post: 11-10-2000, 04:46 AM
By Kevin McGuire in forum VB Classic
Last Post: 09-05-2000, 04:51 PM
By John in forum VB Classic
Last Post: 04-05-2000, 10:04 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center