You should read up on the
Focus aspect of controls (the MSDN is a good place for this information). But in a nutshell this allows you to determine which control has focus, which control is getting focus and which control has lost focus.
The idea behind custom event handlers is that you add or remove some code to the standard event handler of that action.
Consider:
- int x = 10;
-
x += 5; //x now has a value of 15
Using similar logic you can now add some custom code which will be executed when the event is fired.
This MSDN page explains the syntax and logic behind event handlers, have a read and feel free to post any questions if some parts are unclear.
The MSDN speaks of custom event arguments, for the problem which you have, you don't need custom arguments the standard
EventArgs will work fine.
So once you have a subscription you simply put the code you want executed into the procedure you have created for the event. That's all there is to it (I know it sounds like a lot now, but it really isn't too bad - just play around with it a little)
The code you will execute will most probably just set a property of your list box, maybe something like:
- Listbox1.visible = false;
Again feel free to post if you are stuck.
Good Luck