private void timer2_Tick_1(object sender, EventArgs e) { try { if (_codeProvider != null && Settings.TrackActiveItem) { int line; int column; _codeProvider.GetCursorPos(out line, out column); if (line >= 0 && (line != _lastActiveLine || column != _lastActiveColumn)) { CustomTreeNode hightLightNode = null; ScanTreeView(node => { bool sel = false; if (node.CodeNode.StartLine <= line && line <= node.CodeNode.EndLine) { if (node.CodeNode.StartLine == node.CodeNode.EndLine) { if (node.CodeNode.StartColumn <= column && column <= node.CodeNode.EndColumn) { sel = true; } } else { sel = true; } } if (sel) { if (hightLightNode != null && node.Level < hightLightNode.Level) { return(true); //Skip parent nodes } hightLightNode = node; } return(true); }, treeView1.Nodes); _lastActiveLine = line; _lastActiveColumn = column; if (hightLightNode != null && treeView1.SelectedNode != hightLightNode) { treeView1.SelectedNode = hightLightNode; } } } } catch { } }