Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[TUT] How to add dynamically add events. [N00B FRIENDLY]

[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

I love you<3 :3 Will use this in the future.
You can do that for everything, really.

Just a heads up for everyone else.
Cool, easy to understand tutorial
I gonna use this
I appreciated the feedback guys. Thanks a lot.
Quote:EDIT: To remove a handle dynamically, you will need to do this:


yes?

nothing?

i will do nothing?
(Mar 27, 2011 09:28 AM)nathan72389 Wrote:  yes?

nothing?

i will do nothing?

Oops, I dun goofed, I'll fix that now.
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 :)
(May 31, 2011 06:03 AM)Hell Guardian Wrote:  Simply
PHP Code

<?php 
AButton
.Text = Textbox1.Text 

Thanks you! :D
That really helped me :D
I don't see what the use of this is tbh.
Just add a button & add MEssagebox("blablabla") ?
(Jun 11, 2011 12:15 PM)ThΣ Jok3Я ™ Wrote:  I don't see what the use of this is tbh.
Just add a button & add MEssagebox("blablabla") ?

...It could be used for adding buttons at runtime, instead of in the ide, with an event handler.
Code
AddHandler AButton.Click, AddressOf Abutton_ClickHandle 'setting the handle for the Abutton's click event to the subroutine down below

wut. "Setting" the "handle" doesn't make sense, since you can have multiple handlers for a single event.
Aww, thanks you for this. Im going to ues this. :D
Aww, thanks you for this. Im going to ues this. :D


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by Lithium MindJun 20, 2022 09:03 AM 0 159 Jun 20, 2022 09:03 AM
Last Post: Lithium Mind
[C#] by Tr0jandogJan 18, 2021 08:44 AM 7 363 Jan 18, 2021 08:44 AM
Last Post: SIM-4717218
[Python] by 4ground_daemonNov 19, 2019 10:19 PM 5 178 Nov 19, 2019 10:19 PM
Last Post: Wiked™