Re: Handles is just a concise AddHandler
It's counter-intuitive because VB.NET is doing the AddHandler and RemoveHandler for you... So one should use a 'WithEvents' variable and let the compiler take care of it for you, or explicitly use AddHandler and RemoveHandler yourself. But not both!
Paul Vick has a nice discussion of what VB is doing behind the scenes here:
http://www.panopticoncentral.net/archive/2004/08/03/1536.aspx
CJLeit,
I dont have an IDE in front of me, so I cannot test this, but if you really want to use the 'WithEvents' construct here, you should be able to. You should first create a static field somewhere, declaring the variable 'WithEvents' and typed as 'System.Windows.Forms.Binding':
Visual Basic:
Shared WithEvents MyTextBinding As System.Windows.Forms.Binding
After that you should be able to use the dropdown controls within Visual Studio to find your 'MyTextBinding' field and then choose the 'Format' event. The IDE will then create a stub for you.
(Or you probably can simply add 'Handles MyTextBinding.Format' to the end of your existing 'FormatName()' method. I'm not 100% sure of this, but my guess is that this would work.)
Ok, lastly, something has to set your MyTextBinding to actually hold an object. So somewhere in your code you'll need something like this:
Visual Basic:
MyTextBinding = textBox.DataBindings("Text")
To be honest though, if you are comfortable using AddHandler and RemoveHandler, then doing so it probably more direct and clear. I would let the IDE/designer create 'WithEvents' and 'Handles' constructs for the form's controls, but otherwise, use whatever is cleaner and easier for you to use.
Hope this helps...
Mike