I'm trying to create a custom acting TreeView. When you click a node it should toggle as selected/unselected. Currently I can select a node once by clicking it, deselect the node by clicking it again, but I am unable to select the node again via clicking unless I select another node first. Any help would be greatly appreciated.
TreeNode lastNode;
private void treeViewMS1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (lastNode == e.Node)
{
treeViewMS1.SelectedNode = null;
lastNode = null;
}
else
{
if (lastNode == null)
{
treeViewMS1.SelectedNode = e.Node;
}
lastNode = e.Node;
}
}