TreeView Question Part Deux

  • Thread starter Thread starter Michael C
  • Start date Start date
M

Michael C

Hi all,

I half-resolved my previous TreeView issue. Now I was wondering if anyone
knows of a way to keep a TreeNode from being highlighted when it is
left-clicked? It seems like there should be an event I could intercept, or
a property I could set, but I'll be darned if I can figure out which one...

Thanks,
Michael C., MCDBA
 
You can hook on "BeforeSelect" event and set the Cancel property on
TreeViewCancelEventArgs to true.

-vJ
 
I *think* it doesn't work because right-clicking a node doesn't fire the
BeforeSelect and AfterSelect events (maybe because right-clicking doesn't
actually select a node?) I just tried it again, just to make sure, and it
appears right-clicking doesn't fire BeforeSelect.

Thanks,
Michael C., MCDBA
 
Right-clicking does fire the BeforeSelect event on mine. I'm using .Net
1.1.

-vJ
 
I'm using .NET 1.1 also, VS.NET 2003 -- I wired up the BeforeSelect event
and the MouseDown events, and the right-click just isn't firing the
BeforeSelect here... hmmm... I can probably live without that part, it's
just a little annoying is all. Now I'm having an issue with trying to
display a pop-up Context Menu on the right-click. It pops up OK, but until
you click somewhere else on the form to get rid of the Context Menu, you
can't right-click again... I'd like to figure out how to make the Context
Menu close out and pop back up as soon as you right-click anywhere on the
form, whether the menu is up or not... Guess I need to look at ContextMenu
events next.

Geez, everytime I figure out one thing, I have to look up 3 others.

Thanks,
Michael C., MCDBA
 
Context menu should work as it is, unless you're handling the Mouse Down
events in a specific way and that is interfering with the other events.

That could also explain why I get the BeforeSelect and you don't.

-vJ
 
By golly you're probably right... I am intercepting the MouseDown event,
although I'm not doing anything I would think would interfere with the other
events... I even tried calling the base.OnMouseDown(e) event in my own
MouseDown event handler, but it still seems to be interfering... strange...
I think I found a workaround, basically using the ContextMenu PopUp event to
handle everything; stranger and stranger. It seems like a simple thing I
want to do, but it gets more and more complicated as I go.

Thanks,
Michael C., MCDBA
 
Back
Top