Hi,
My ListBox code is displayed in the .Opening event. I have a button to “Refresh” the information. Is it possible to call the DesktopListbox.Opening event from a button (so without moving the code)?
Daniel.
one way would be to move all the code from the DesktopListbox.Opening event to a method. DesktopListbox.Opening would only call the method, and so would the button.
I think a better way to do this would be to put the code in a method and then you can call it from both the .Opening event and your button.
(edit: oops. Louis D got there first!)
This is a first. There is always someone faster and better than I am.
To answer your specific question, the answer is no. You don’t call specifically an Event from code. An Event is a notification - a message in OOPS parlance - that the app receives, for example “a control is opening”, “a button was pressed”, etc. The app reacts to this message by executing the code in an Event Handler. This code is a block linked to the Event. To create this block of code, you select the Control, right-click on it - or use the button on the top bar - and select the Event. The Editor brings you to the code block for this Event, empty at thsi moment.
Back to what you wish to do. You need to have a button that will trigger a refresh of the displayed information. On top of that, when a Control is created, you also need to display (refresh) the same information. To achieve this:
- Create a Method that will refresh the information, lets call it RefreshData.
- In the .Opening Event, call RefreshData
- In the .Pressed Event of the button, call RefreshData
In fact you may call , call RefreshData any time there is a condition that needs to refresh the information.