ComponentFactory / Krypton

Krypton WinForms components for .NET
BSD 3-Clause "New" or "Revised" License
1.85k stars 681 forks source link

Treeview #75

Open herledant opened 6 years ago

herledant commented 6 years ago

Hello,

First thank's a lot for this wonderful toolbox !

I meet a problem with treeview event. I devlop with vb.net and when i use the mouseclick, mousedown, click etc event, nothing happened.

Could you help me to use the component correctly?

for example:

 Private Sub treeviewPvt2_MouseClick(sender As Object, e As MouseEventArgs) Handles TreeViewPvt.MouseClick

msgbox("works")

end sub

This is not work.

Kind's regards

herledant commented 6 years ago

Hello, Somebody meet this issue to or it's just me? it's seems that all event for this component doesn't work.

Thank's for help

Smurf-IV commented 6 years ago

Not all event are "Forwarded" through from the Krypton overriden control.

Attach your events to the underlying type i.e. treeviewPvt2.TreeView.MouseClick += ............

herledant commented 6 years ago

Hello Smurf-IV, Thank's for you answer but i'm affraid i dont understand.

I try this in the form load but no succes:

AddHandler TreeViewPvt2.Click, AddressOf treeviewPvt2_click

Sorry,but coul'd you give me a complete exemple?

Thank's again

MGRussell commented 6 years ago

Many controls, like KryptonTreeView, wrap around another Control. Unfortunately since the Krypton controls all also inherit from VisualControlBase which inherits from Control, this means any part of the interface that is not explicitly passed down to the wrapped control gets hidden. And what is or is not passed down is not entirely consistent. See Issue 62 for another example of where this popped up.

So, the solution:

        var treeView = new KryptonTreeView();
        treeView.ContainedControl.Click += TreeView_Click;

ContainedControl is available for all KryptonControls which wrap around another control.

herledant commented 6 years ago

Hello FreeFlyingEnchilada,

Thank's for your time and answer. Therefore i must be stupid because i don't manage the treeview_click.

As i said, i code in VB.Net. But i should be the same. Mya treeview is created by the designer so i can call it directly.

if i use the following code in the form_load event:

Private Sub biolis_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      TreeViewPvt2.ContainedControl.Click += TreeViewPvt2_Click(sender, e)
end sub

Private Sub TreeViewPvt2_Click(sender As Object, e As EventArgs) 'Handles TreeViewPvt2.Click
        MsgBox("test")
End Sub

Ide ask me for a raise Event and tell me that "TreeViewPvt2_Click" dont produce any value. I know this question go beyong the inital question but if somebody can explain me it would be great.

Thank's again for your time. Kind's regards

Smurf-IV commented 6 years ago

NodeMouseClick is routed through. If you use the branch WangerP 47b nuget, then the _treeView.Click += OnTreeClick; // SKC: make sure that the default click is also routed. is also routed

herledant commented 6 years ago

Hello Smurf-IV,

The WangerP 47B branch is only for 4.7.net but i keep this information for a next time.

In VB.net the syntax is:

AddHandler myTree.ContainedControl.Click, AddressOf MyTree_Click

 Private Sub MyTree_Click()
        MsgBox("ok")
 End Sub

Thank's a lot