c# - get treenode under cursor -
basically have treeview populated numerous image files. trying make nodemousehover event bring little preview of image. need find out node mouse over, cannot work, unable find tree node @ cursor position.
here simplified version code
private void treebroswer_nodemousehover(object sender, treenodemousehovereventargs e) { string filepath; picturebox preview; treenode test = treebroswer.getnodeat(cursor.position.x, cursor.position.y); //also tried mouseposition.x,mouseposition.y if (test == null) { messagebox.show("no tree node"); } else { filepath = test.fullpath; preview = new picturebox(); preview.imagelocation = @filepath; // display preview } }
it fails tree node no matter mouse is. not sure if getting mouse position wrong or i'm using getnodeat wrong, or both.
the parameter event - treenodemousehovereventargs
- has information need.
just reference e.node
see node mouse hovering over. if you're not hovering on node, event won't fire, no need check null.
private void treebroswer_nodemousehover(object sender, treenodemousehovereventargs e) { var preview = new picturebox { imagelocation = e.node.fullpath }; // display preview }
Comments
Post a Comment