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
2
votes
4 answers

AddHandler for custom controls error visual studio

I have a MouseEnter event which currently handles some custom controls on my form. The program is a card game. I have a collection (handCards) that gets populated when the user draws a card and then it adds the latest card to the form. This…
codenaugh
  • 857
  • 2
  • 12
  • 27
1
vote
1 answer

Dynamically AddHandler

I have a large number of buttons on a form (144 buttons). The names of each button is a combination of different factors. I need them to all do the same thing when pressed. I have this event under a Private Sub called "ClickButton". I want to use a…
Pejman Poh
  • 493
  • 2
  • 8
  • 20
1
vote
4 answers

Send parameter to addhandler?

I have a button in a grid that I created programmatically. The button edits some data in a table using data in a hidden column of the grid that the button is in. Normally I send a hidden field the row data using javascript onclientclick of the…
Eric
  • 7,930
  • 17
  • 96
  • 128
1
vote
1 answer

Does an AddHandler require parameters?

I'm trying to add a handler, but as soon as I'm targetting a method that has parameters, the handler fails. This is the simple code: AddHandler App.Current.RootVisual.MouseLeftButtonUp, RootVisual_MouseLeftButtonUp Private Sub…
Terry
  • 5,132
  • 4
  • 33
  • 66
1
vote
1 answer

Keep getting error when using eventhandler, syntax error

I am trying to control when a event is firing and having some issus. This is what I tried ,following the documentation on MSD Can anybody see the error here? BC30677 Visual Basic or statement event operand must be a dot-qualified expression or a…
Bertil
  • 25
  • 4
1
vote
0 answers

Handling MouseDownEvent of ToggleButton in Silverlight 4

I'm trying to handle the MouseDownEvent for this control by adding a hook to RootVisual: Application.Current.RootVisual.AddHandler(MouseLeftButtonDownEvent, (MouseButtonEventHandler)OnMouseLeftButtonEvent, true); But even though I set the last…
vlaku
  • 1,534
  • 2
  • 14
  • 27
1
vote
0 answers

AddHandler for Cisco AnyConnect

I'm trying to create code to auto detect a drop in VPN connection and general internet connection (as well as when it reconnects to both). I've tried AddHandler with the VpnApiClass (every action in intellisense) and…
Michael K
  • 11
  • 2
1
vote
2 answers

Addhandler, button.click not firing using VB.NET

I am experiencing a problem with buttons and AddHandler. It only works if I use AddHandler Button1.click, AddressOf... in Page_load, but if I create the button dynamically in one of the sub routines, the event doesn't fire. For example,
user649904
  • 33
  • 1
  • 1
  • 5
1
vote
0 answers

VB.NET Add handler without event handler?

Is there a way for me to just specify an event handler without creating a new sub? For example... Normally I would do something like the following: AddHandler btn.click, EventHandler OpenDirectory Private Sub OpenDirectory …
gCanuck
  • 39
  • 1
  • 6
1
vote
2 answers

AddHandler .htaccess on GoDaddy stopped working today

I have the following code in my GoDaddy .htaccess file: AddHandler fcgid-script .do FCGIWrapper /usr/local/cpanel/cgi-sys/php .do AddType application/x-httpd-php5 .do This means that whenever we go to a ".do" file in the web browser, it runs as…
user3931836
  • 184
  • 1
  • 11
1
vote
4 answers

Where to "destroy" Handlers in VB.NET classes?

I have some class (a user control) MyUserControl that rises events. I use it in a form MyForm, in that, for some reasons I am forced to use AddHandler instead of WithEvents<>Handles pair. I use AddHandlers in the MyForm_Load method. Now. Adding…
serhio
  • 28,010
  • 62
  • 221
  • 374
1
vote
1 answer

Addhandler fcgid-script.php error

Recently I started using Scriptcase and it requires me to first install PHP and apache. During apache installation, I need to make some modification in httpd.conf, which is located in C:\apache24\conf I added contents in the script as following:…
Gan
  • 43
  • 1
  • 3
1
vote
1 answer

Dimming Control by String and adding handler

I want to add a handler to a control that i find by its name. The Problem is that it is not possible to Dim an control from a Button or RadioButton or something like this... Dim control As Control = FindName(MyObject.Name.ToString) …
1
vote
1 answer

How to "AddHandler" trying to catch an event from an external library

I want to call a function as soon as an event from an external library occurs. I have an array of camera objects (different cameras) which create an event as soon as they grab an image (triggered externally). The cameras are defined by an external…
Martin S
  • 15
  • 4
1
vote
0 answers

PHP AddHandler Blocking Another AddHandler

I am trying to run a PHP script on an html page and I have figured out that I need to add the following to my htaccess file: AddHandler application/x-httpd-php .html So I did that and it allowed the PHP script to run as needed, but it also blocked…