protected override void OnNodeMouseClick(TreeNodeMouseClickEventArgs e) { Console.WriteLine(e.Location + " bounds:" + e.Node.Bounds); TreeNode3 n = e.Node as TreeNode3; if (e == null) { return; } if (cbx(n.Bounds, 0).Contains(e.Location)) { n.Check1 = !n.Check1; } else if (cbx(n.Bounds, 1).Contains(e.Location)) { n.Check2 = !n.Check2; } else if (cbx(n.Bounds, 2).Contains(e.Location)) { n.Check3 = !n.Check3; } else { if (SelectedNode == n && Control.ModifierKeys == Keys.Control) { SelectedNode = SelectedNode != null ? null : n; } else { SelectedNode = n; } } Console.WriteLine(" " + n.Check1 + " " + n.Check2 + " " + n.Check3); Invalidate(); }
public TreeNode3 AddNode(string label, bool check1, bool check2, bool check3) { TreeNode3 node = new TreeNode3(label, check1, check2, check3); this.Nodes.Add(node); return(node); }
protected override void OnDrawNode(DrawTreeNodeEventArgs e) { TreeNode3 n = e.Node as TreeNode3; if (n == null) { e.DrawDefault = true; return; } CheckBoxState cbyTrue = CheckBoxState.CheckedNormal; CheckBoxState cbyFalse = CheckBoxState.UncheckedNormal; Rectangle rect = new Rectangle(e.Bounds.Location, new Size(ClientSize.Width, e.Bounds.Height)); glyph = CheckBoxRenderer.GetGlyphSize(e.Graphics, cbyTrue); if (n.IsSelected) { e.Graphics.FillRectangle(SystemBrushes.MenuHighlight, rect); e.Graphics.DrawString(n.Label, Font, Brushes.White, e.Bounds.X + 55, e.Bounds.Y); } else { CheckBoxRenderer.DrawParentBackground(e.Graphics, e.Bounds, this); e.Graphics.DrawString(n.Label, Font, Brushes.Black, e.Bounds.X + 55, e.Bounds.Y); } CheckBoxState bs1 = n.Check1 ? cbyTrue : cbyFalse; CheckBoxState bs2 = n.Check2 ? cbyTrue : cbyFalse; CheckBoxState bs3 = n.Check3 ? cbyTrue : cbyFalse; CheckBoxRenderer.DrawCheckBox(e.Graphics, cbx(e.Bounds, 0).Location, bs1); CheckBoxRenderer.DrawCheckBox(e.Graphics, cbx(e.Bounds, 1).Location, bs2); CheckBoxRenderer.DrawCheckBox(e.Graphics, cbx(e.Bounds, 2).Location, bs3); }
public void AddNode(string label, string name, bool check1, bool check2, bool check3, object tag) { TreeNode3 node = new TreeNode3(); node.Check1 = check1; node.Check2 = check2; node.Check3 = check3; node.Label = label; node.Name = name; node.Tag = tag; this.Nodes.Add(node); }
protected override void OnNodeMouseClick(TreeNodeMouseClickEventArgs e) { //base.OnNodeMouseClick(e); Console.WriteLine(e.Location + " bounds:" + e.Node.Bounds); TreeNode3 n = e.Node as TreeNode3; if (e == null) { return; } TreeNode nSel = SelectedNode; if (cbx(n.Bounds, 0).Contains(e.Location)) { n.Check1 = !n.Check1; } else if (cbx(n.Bounds, 1).Contains(e.Location)) { n.Check2 = !n.Check2; } else if (cbx(n.Bounds, 2).Contains(e.Location)) { n.Check3 = !n.Check3; } else { if (nSel == n && Control.ModifierKeys == Keys.Control) { SelectedNode = SelectedNode != null ? null : n; } else { SelectedNode = n; } } Console.WriteLine(" " + n.Check1 + " " + n.Check2 + " " + n.Check3); Invalidate(new Rectangle(0, e.Node.Bounds.Y, ClientSize.Width, n.Bounds.Height)); }