/* * [Function] * highlight tree node * [Input] * some TreeNode * * [Output] * set color to highlighted color * * [Note] */ public Color highlightNode(TreeView trvValue, TreeNode someNode) { Color oldColor = trvValue.BackColor; //"{Name=Window, ARGB=(255, 255, 255, 255)}" if (someNode != null) { oldColor = someNode.BackColor; //"{Name=0, ARGB=(0, 0, 0, 0)}" // HTML #3399FF -> RGB(51,153,255) //"{Name=MenuHighlight, ARGB=(255, 51, 153, 255)}" someNode.BackColor = SystemColors.MenuHighlight; //node.BackColor = nodeHlBackColor; //node.ForeColor = Color.FromArgb(255, 255, 255); someNode.ForeColor = Color.White; } return oldColor; }
例 1.3. highlightNode的使用范例
if (e.ClickedItem == tsmiAddToSelection) { if (!curSelTreeNodeList.Contains(curSelTreeNode)) { // add to selection curSelTreeNodeList.Add(curSelTreeNode); //hightlight node crl.highlightNode(trvCategoryTree, curSelTreeNode); } }