locked
an ambiguous behavior of MouseClick event in Treeview control RRS feed

  • Question

  • In this case:  a treeview control is newly created and there isn't any treenode inside it.


    when I use "MouseClick" event, i coultnot activate this event when I click the treeview zone, unless I add nodes to the treeview and click the zone where there's treenodes in the left.

    ww4.sinaimg.cn/large/ed75e886gw1f0fjc2p3rpj208106h74k.jpg←←←←←please see this image

    However!!!! when I set the treeview's property"ContextMenuStrip" , whereever I right click, the menu pop out correctly.

    So if I have to use my menu I have to use "MouseDown" rediculously rather than "MouseClick“, which works whereever inside the treeview zone.

    I want to know why "MouseClick"doesn't happen in the red zone in the aforementioned jpg.

    And also, I was wondering what is such confusing design's purpose? Is it my misunderstanding, or I do something not correctly, or Microsoft's mistake/Bug, or something unevadable that Microsoft can do nothing to handle it(because it is the base class's method...)




    • Edited by TruffleWorm Thursday, January 28, 2016 1:35 PM
    Thursday, January 28, 2016 1:33 PM

Answers

  • Hi TruffleWorm,

    I can reproduce your issue.

    >> However!!!! when I set the treeview's property"ContextMenuStrip" , whereever I right click, the menu pop out correctly.

    This is the how the context menu works. So I think this is not related to mouse click event.

    >> And also, I was wondering what is such confusing design's purpose? Is it my misunderstanding, or I do something not correctly, or Microsoft's mistake/Bug, or something unevadable that Microsoft can do nothing to handle it(because it is the base class's method...)

    Personally I think it is just the by designed issue for this control. I’m not so sure why is it designed like this. But can you describe what you actually want to do in this event? Maybe we can think about a relevant way to do the same.

    By the way, maybe we can check the code from the .NET Open Source site: http://referencesource.microsoft.com/

    Best regards,

    Moonlight


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, January 29, 2016 9:14 AM