In Treeview, i want to expand the nodes by my own, but when the user doubleclik or use plus (+) keys, the node expands likewise to collapse. I want to populate those functions of my own. is there any way?
Thanks
ackid32 Friday, June 08, 2007 12:36 PM
Next time, mention that you are unable to read C# code.
Public Class MyTreeView Inherits TreeView Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) ' Filter double-click messages If m.Msg = &H203 Or m.Msg = &H206 Then Return ' Filter +,- keystrokes If m.Msg = &H100 Then If m.WParam.ToInt32() = CInt(Keys.Subtract) Then Return If m.WParam.ToInt32() = CInt(Keys.Add) Then Return End If MyBase.WndProc(m) End Sub End Class
nobugz Monday, June 11, 2007 7:07 AM
You'll have to prevent the Windows messages from reaching the native TreeView control. Add a new class to your project and paste the code below. Build. Drop the new control from the top of the toolbox onto your form. You may want to customize the code to build in your own behavior.
using System; using System.Windows.Forms;
public class MyTreeView : TreeView { protected override void WndProc(ref Message m) { // Filter double-click messages if (m.Msg == 0x203 || m.Msg == 0x206) return; // Filter +,- keystrokes if (m.Msg == 0x100) { if (m.WParam.ToInt32() == (int)Keys.Subtract) return; if (m.WParam.ToInt32() == (int)Keys.Add) return; } base.WndProc(ref m); } }
nobugz Friday, June 08, 2007 6:38 PM
i'm using vb.net, so please convert this into VB
ackid32 Monday, June 11, 2007 6:50 AM
Next time, mention that you are unable to read C# code.
Public Class MyTreeView Inherits TreeView Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) ' Filter double-click messages If m.Msg = &H203 Or m.Msg = &H206 Then Return ' Filter +,- keystrokes If m.Msg = &H100 Then If m.WParam.ToInt32() = CInt(Keys.Subtract) Then Return If m.WParam.ToInt32() = CInt(Keys.Add) Then Return End If MyBase.WndProc(m) End Sub End Class