TreeView with CheckBox

If you wanna use CheckBox enabled TreeView in Windows Vista and further systems, you need to pay attention. If you double click the CheckBoxes in the TreeView, some useful event handlers, like BeforeClick and AfterClick, will not be raised. And, the vision of CheckBoxes will be changed (checked or not) but the property of related TreeNode will not.

To fix this, you have to create your own TreeView instead of the provided one.

using System;
using System.Windows.Forms;
public class FixedTreeView : TreeView {
protected override void WndProc(ref Message m) {
if (m.Msg == 0x203) { m.Result = IntPtr.Zero; }
else base.WndProc(ref m);


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.