![]() |
|
[.NET] [TUT] How to add dynamically add events. [N00B FRIENDLY] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] [TUT] How to add dynamically add events. [N00B FRIENDLY] (/showthread.php?tid=1161961) |
[TUT] How to add dynamically add events. [N00B FRIENDLY] - Cody8295 - Mar 26, 2011 [TUT] How to add dynamically add events. [N00B FRIENDLY] Note: I will not use any code tags or include any text code, simply for the fact that you cannot C&P this. If you don't already know how to do this, you'll have to learn. I will use pictures from which you can READ and UNDERSTAND the code. Alright, I wrote this simple tutorial because it's pretty easy and very helpful. Everyone should know how to do this. Step 1.) Create a new project and give it a name- [img]http://content.screencast.com/users/codydv/folders/Jing/media/33564288-0247-435f-97a1-9b754ac5e4fe/2011-03-26_2319.png[/img] Step 2.) Double click the form to bring up the Form_Load code- [img]http://content.screencast.com/users/codydv/folders/Jing/media/7e6db3c0-bc52-4fd1-9cd7-f5cff3378354/2011-03-26_2322.png[/img] Step 3.) Study the code below and try it out- [img]http://content.screencast.com/users/codydv/folders/Jing/media/1f0e0542-aec7-4873-9ca0-f26dab695580/2011-03-26_2328.png[/img] Step 4.) You're done! Try it out. [img]http://content.screencast.com/users/codydv/folders/Jing/media/0adce992-600a-4f0d-bf86-9be304ff212c/2011-03-26_2329.png[/img] Thanks for reading. And I know it's a pretty small tutorial but it's mainly for beginners. EDIT: To remove a handle dynamically, you could simply use the RemoveHandler method. Code RemoveHandler abutton.click, abutton_click* - Deceptive - Mar 26, 2011 I love you<3 :3 Will use this in the future. * - iiTzUncleSam - Mar 26, 2011 You can do that for everything, really. Just a heads up for everyone else. * - wir - Mar 26, 2011 Cool, easy to understand tutorial I gonna use this * - Cody8295 - Mar 27, 2011 I appreciated the feedback guys. Thanks a lot. * - nathan72389 - Mar 27, 2011 Quote:EDIT: To remove a handle dynamically, you will need to do this: yes? nothing? i will do nothing? * - Cody8295 - Mar 27, 2011 (Mar 27, 2011 09:28 AM)nathan72389 Wrote: yes? Oops, I dun goofed, I'll fix that now. * - Son_Of_Diablo - May 31, 2011 Nice tut thanks! :D I just have one question: How can i tell it to add a button with the name from TextBox1.text ? Thanks :) * - Son_Of_Diablo - May 31, 2011 (May 31, 2011 06:03 AM)Hell Guardian Wrote: Simply Thanks you! :D That really helped me :D * - ThΣ Jok3Я ™ - Jun 11, 2011 I don't see what the use of this is tbh. Just add a button & add MEssagebox("blablabla") ? * - Cody8295 - Jun 11, 2011 (Jun 11, 2011 12:15 PM)DaM| Wrote: I don't see what the use of this is tbh. ...It could be used for adding buttons at runtime, instead of in the ide, with an event handler. * - Zer0Fact0r - Jun 11, 2011 Code AddHandler AButton.Click, AddressOf Abutton_ClickHandle 'setting the handle for the Abutton's click event to the subroutine down belowwut. "Setting" the "handle" doesn't make sense, since you can have multiple handlers for a single event. * - Eclipse - Jun 11, 2011 Aww, thanks you for this. Im going to ues this. :D * - Eclipse - Jun 11, 2011 Aww, thanks you for this. Im going to ues this. :D |