|
-
Feb 8th, 2010, 08:11 PM
#9
Thread Starter
Member
Re: How to dynamically create TextBox in VB.NET
 Originally Posted by jmcilhinney
It's possible, as has been shown, but there's no need or reason to do so. You wouldn't identify the controls by name. What you would do is write a single event handler for the same event of every control. When you create the control you use AddHandler to attach the event handler. In the event handler, you use the 'sender' parameter to access the object that raised the event.
The way to go about this is to start by NOT creating the controls at run time. Just start with a blank form and add a single control in the designer. You then add the appropriate event handlers and all the code to make that control behave the way you want. In all the event handlers, make sure you access the control via the 'sender' parameter rather than by its member variable. Once that's all done, you simply remove all the Handles clauses and copy the event handlers into your real project. You then use AddHandler to connect your dynamic controls to your event handlers and it will all just work.
Can you show me some example...@@ ???
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
|