79521691

Date: 2025-03-20 01:23:36
Score: 1
Natty:
Report link

The NodeMouseClick event can be called from the BeforeExpand event, passing the latter's sender object and a TreeNodeMouseClickEventArgs constructed from BeforeExpand's Event Args, well mostly. If the X and Y args aren't needed, pass nulls. Otherwise these values, which differ by a few pixels from the X,Y values passed to NodeMouseClick, may be cached during the MouseDown event preceding BeforeExpand, then used in the latter. Calling NodeMouseClick this way results in no double firing apparently because the call is flagged internally and can only fire once until such flag is reset, which would be at least following the AfterExpand event. However, a blocking bool could be set in NodeMouseClick and cleared in AfterExpand or MouseUp if one were concerned about it. Anyway, the NodeMouseClick can be forced to happen for the last node in the tree at the current level, which would not happen in the normal usage unless there is sufficient clearance between the last node and the lower edge of the Treeview window, and this seems to be a design bug.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Phil G