Anthony
Anthony

Reputation: 387

How do I delay an event handler to run a small bit of code first?

I'm curious if there is a way to intercept a control event handler long enough to run a small block of code, and then continue on to that handler.

For instance, say I have a TreeView on my form, and when I click to expand a node, I want to run some code for that node before it actually expands, perhaps some sort of On-demand loading of sub-nodes or something similar.

Right now I can run code when it's clicked in the tree views NodeMouseClick event, but I would like for the node to not expand until after that code is complete.

Thoughts?

Upvotes: 2

Views: 183

Answers (1)

larsmoa
larsmoa

Reputation: 12932

TreeView.BeforeExpand let's you do just that.

Also, event handlers are blocking - only one event handler will run at the same time and they also block the GUI (if you don't explicitly take any actions to prevent it).

Upvotes: 3

Related Questions