Questions tagged [addhandler]

AddHandler (and the companion RemoveHandler) is used to add (and remove) event handlers dynamically in VB.NET

Add and remove event handlers dynamically in .NET

.NET lets you add and remove Event Handlers dynamically on the fly. Your code can start and stop handling events at any time during program execution. Also, you can tie the same code (event handler) to multiple events similar to the Handles clause in VB.NET.

The VB.NET AddHandler and RemoveHandler statements allow this behavior. Both statements take two arguments: the name of the event to handle and the name of the procedure that will handle the event.

93 questions
1
vote
4 answers

Add EventHandler to object of unknown type?

We're creating objects at runtime so before running the code doesn't know what object it is working with. We want to add an event handler to every TextBox which is created at runtime. But when we try AddHandler obj.Leave, AddressOf leaveControl the…
Dyrdek
  • 411
  • 4
  • 12
  • 33
1
vote
1 answer

Difference between Handles declaration and AddHandler for SystemEvents in VB.NET

I'm using a device driver which I need to close when the system goes to sleep. I thought I could add a handler for the SystemEvents.PowerModeChanged event to ApplicationEvents.vb as follows: Public Sub SystemEvents_PowerModeChanged(sender As…
kvermeer
  • 458
  • 3
  • 12
1
vote
2 answers

Create a dynamic control and AddHandle WITH Values/Brackets

it seems that adding for example a button Dim myButton as New Button and then addHandler to mySub("lol", 255) is not possible. Where mySub is Shared Sub MySub(byRef myString as string, myInteger as Integer) So: addHandler myButton.click, addressOf…
Jacob Kofoed
  • 77
  • 4
  • 9
1
vote
1 answer

custom php.ini and rewriterule in .htaccess

I have a php application, which requires an .htaccess file with this rewriterule in it: RewriteRule .* blog_manager/controller/frontController.php I've opened a new hosting account and I wanted them to disable the extension:…
Alon Dor
  • 111
  • 10
1
vote
2 answers

AddHandler vs. Handles - what is the difference?

I understood that Handles is only one way to add in constructor the AddHandler, but in general are these two are equivalent?
serhio
  • 28,010
  • 62
  • 221
  • 374
1
vote
0 answers

AddHandler on localhost (xampp)

I just install the newest version of Xampp. It was running PHP Version 5.4.7. The problem I'm encounter is some of my client's website is build with 5.1 or 5.2 and some function are deprecated. So, I'm trying to change the php version on those…
Gummi
  • 13
  • 4
1
vote
1 answer

VB .net Context/ToolStripMenu at runtime

I have a ContextMenu like in this picture. Now i want to add where it says ".rtf" more MenuItems at runtime. I cant seem to make it... Dim myContextMenu As ContextMenuStrip = Form1.mnuOptions Dim myMenuItem As ToolStripMenuItem =…
drumbun
  • 61
  • 5
1
vote
3 answers

Setting up Apache on Ubuntu LAMP Server to execute Python in Virtual Host

I am trying to setup a LAMP server in my lab, and I'm having trouble getting Apache to execute the .py files. It instead just downloads them. At first I thought my header might be wrong, but when I changed it, it unfortunately I'm still not…
Atl LED
  • 656
  • 2
  • 8
  • 31
1
vote
0 answers

Dynamic button not working with AddHandler in VB.NET

I am working on a project in which I am trying to create a button dynamically in the code-behind dynamically to submit and upload a file to the server. I am using AddHandler, but the button will not post back. I read everywhere that I need to…
1
vote
1 answer

How to disable script execution with .htacces

This is my virtual host configuration file ServerAdmin yo@my-domain.tld ServerName my-domain.tld ServerAlias www.my-domain.tld DocumentRoot /home/my-domain/public_html Options…
hex494D49
  • 9,109
  • 3
  • 38
  • 47
0
votes
1 answer

How do I apply AddHandler using OnCommand in ASP.NET

I've been racking my brain trying to get this to work. My event for my LinkButton isn't firing. I'm figuring that it has SOMETHING to do with ViewState and that the button is not there when it tries to fire the event after the Postback or…
RichC
  • 7,829
  • 21
  • 85
  • 149
0
votes
1 answer

powerpoint before print

I can get winword and excel beforeprint events, but in powerpoint I can't. Can anyone show me a link that points me when the slides or presentation beforeprint in powerpoint: how? thanks in advance
xenblaise
  • 5
  • 4
0
votes
1 answer

VB.Net Make Event through loop was duplicated

I have a snip code to show how a list of events was created. While tb.MoveNext() Try idMenu = tb.Current.Field(Of Integer)("idMenu") menuName = tb.Current.Field(Of String)("HeaderName") ClassType = tb.Current?.Field(Of…
DevGold
  • 39
  • 1
  • 4
0
votes
1 answer

VB.NET AddHandler to each button control while looping through controls

I am trying to add mouseenter and mouseleave events to each button while I'm looping through the controls like: For each control in me.controls With control If TypeName(control) = "Button" Then AddHandler…
Eduards
  • 68
  • 2
  • 20
0
votes
1 answer

Create Event handles dynamically using variable as the actions

I'm try to improve our dynamic reporting system. I would like to add event handle to the object I've dynamically created on the form. One of the functions of this would be to populate a listbox from what was selected in the first listbox. i.e. The…
Sean ZA
  • 5
  • 1
  • 4