public int Fill() { this.Items.Clear(); Debug.Assert(this.ResTree != null, "this.ResTree == null错误"); TreeNode curtreenode = this.ResTree.SelectedNode; if (curtreenode == null) { return(0); } for (int i = 0; i < curtreenode.Nodes.Count; i++) { TreeNode child = curtreenode.Nodes[i]; ListViewItem item = new ListViewItem(child.Text, child.ImageIndex); NodeInfo nodeinfo = (NodeInfo)child.Tag; item.Tag = nodeinfo; if (nodeinfo != null) { item.SubItems.Add(nodeinfo.Rights); string strState = ""; strState = NodeInfo.GetNodeStateString(nodeinfo); /* * if ((nodeinfo.NodeState & NodeState.Account) == NodeState.Account) * strState = "帐户定义"; * if ((nodeinfo.NodeState & NodeState.Object) == NodeState.Object) * { * if (strState != "") * strState += ","; * strState = "对象"; * } */ item.SubItems.Add(strState); } if (nodeinfo == null || nodeinfo.Rights == "") { item.ForeColor = SystemColors.GrayText; // ControlPaint.LightLight(nodeNew.ForeColor); } else { item.ForeColor = SystemColors.WindowText; } this.Items.Add(item); } return(0); }
private void ResRightTree_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { string strText = ""; // Point p = this.PointToClient(new Point(e.X, e.Y)); //TreeNode selection = this.GetNodeAt(p); TreeNode selection = this.GetNodeAt(e.X, e.Y); if (m_oldHoverNode == selection) { return; } if (selection != null) { selection.BackColor = SystemColors.Info; NodeInfo nodeinfo = (NodeInfo)selection.Tag; if (nodeinfo != null) { string strState = ""; strState = NodeInfo.GetNodeStateString(nodeinfo); if (nodeinfo.Rights == null) { strText = "对象 '" + selection.Text + "' 权限 -- (未定义); 状态--" + strState; } else if (nodeinfo.Rights == "") { strText = "对象 '" + selection.Text + "' 权限 -- (空); 状态--" + strState; } else { strText = "对象 '" + selection.Text + "' 权限 -- " + nodeinfo.Rights + "; 状态 -- " + strState; } } } toolTip1.SetToolTip(this, strText); if (m_oldHoverNode != selection) { if (m_oldHoverNode != null) { m_oldHoverNode.BackColor = SystemColors.Window; } m_oldHoverNode = selection; } }