private void treeViewHost_MouseDown(object sender, MouseEventArgs e)
{
TreeViewHitTestInfo hitInfo = treeViewHost.HitTest(e.Location);
if(e.Button == MouseButtons.Left &&
(hitInfo.Location == TreeViewHitTestLocations.StateImage ||
hitInfo.Location == TreeViewHitTestLocations.Label))
{
// mouse down in area of state image or label.
TreeNode node = hitInfo.Node;
if(node.Nodes.Count > 0)
// cancel the expand or collapse of node which has children.
m_cancelExpandOrCollapse = true;
// active the node.
ActiveNode(node);
// select or un-select the node.
CheckState checkState = (CheckState)((node.StateImageIndex + 1) % 2);
UpdateNodeCheckStatus(node, checkState);
pictureBoxPreview.Refresh();
}
}