Dear all,
I'm currently experiencing one tiny but irksome issue with the WinTree. If the control is data-bound and its BeforeSelect is handled to cancel selection (I intend to select programmatically after a half-second delay), then the focus rectangle that's displayed around the clicked-upon node is missing its bottom border. If the node hierarchy is built-up manually, however, then this problem doesn't materialise, and I get a nice, full dotted border around the item.
Obviously, it's a tiny detail, but it does impact upon the tree's appearance, so any help you guys could give me would be greatly appreciated.
Many thanks,
James
The DrawFocusRect API has some invalidation issues and this sounds like one of them. You probably just have to invalidate the control, i.e., call UltraTree.Refresh after programmatically selecting the node.
Hey Brian,
Many thanks for replying! Unfortunately, refreshing the tree doesn't appear solve this particular problem, as the form below hopefully demonstrates. If you pass false to SetDataSource(), all is well with the focus rectangle that's drawn; if you pass true (to use a data source), then the focus rect is missing its bottom border. This happens whether data binding is set up at runtime or in the designer.
Please could let me know your thoughts on this?
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.Drawing;using System.Text;using System.Windows.Forms;
using InfragisticsTests;using Infragistics.Win;using Infragistics.Win.UltraWinTree;
public class TreeViewHierarchyTests : Form { public UltraTree tree = new UltraTree(); struct SomeNode { public string t { get; set; } public BindingList<SomeNode> c { get; set; } } public TreeViewHierarchyTests() { this.Text = "Tree Test"; this.Load += new EventHandler(TreeViewHierarchyTests_Load);
tree.Dock = DockStyle.Fill; tree.BeforeSelect += new BeforeNodeSelectEventHandler(tree_BeforeSelect); this.Controls.Add(tree); }
private void TreeViewHierarchyTests_Load(object sender, EventArgs e) { SetDataSource(true);
tree.ColumnSettings.BorderStyleCell = UIElementBorderStyle.None; tree.ColumnSettings.LabelPosition = NodeLayoutLabelPosition.None; }
void SetDataSource(bool useBinding) { if (useBinding) { BindingList<SomeNode> ds = new BindingList<SomeNode>(); ds.Add(new SomeNode() { t = "text1 " , c = new BindingList<SomeNode> { new SomeNode { t = "text1.1" } } }); ds.Add(new SomeNode() { t = "text2" , c = new BindingList<SomeNode> { new SomeNode { t = "text2.1" } } }); ds.Add(new SomeNode() { t = "text3" , c = new BindingList<SomeNode> { new SomeNode { t = "text3.1" } } });
tree.DataSource = ds; } else { tree.Nodes.Add("key1", "text1"); tree.Nodes[0].Nodes.Add("key1.1", "text1.1"); tree.Nodes.Add("key2", "text2"); tree.Nodes[1].Nodes.Add("key2.1", "text2.1"); tree.Nodes.Add("key3", "text3"); tree.Nodes[2].Nodes.Add("key3.1", "text3.1"); } }
private void tree_BeforeSelect(object sender, BeforeSelectEventArgs e) { e.Cancel = true; } }
That is a bug which will be addressed in a future release. You should report the issue and reference bug ID 16599.