I have tried every solution mentioned on these forums, with multiple variations, and the active node is still not highlighted (with background color) when the tree is loaded.
I set the tree data source to a dataset and expanded everything, this all works great.
I then tried several variations of the below, but the node is never highlighted.
var node = ultraTree1.GetNodeByKey("5"); ultraTree1.SelectedNodes.Clear(); node.BringIntoView(); ultraTree1.ActiveNode = node; ultraTree1.HideSelection = false; node.Selected = true;
The active node is correct and loads my list view with the related data. Even trying to override the back color didn't work. When I manually select the node, it highlights properly.
Hello Sam,
I have placed the code you have provided into my sample, and I was able to reproduce the behavior you are seeing. I believe the issue you are seeing here is due to 2 things:
1. I believe that trying to set the Active and Selected node right after you assign the data source is likely too early and you are hitting a timing issue between trying to set these things and when the tree has actually finished loading. I would recommend setting this in the Form’s Load event instead.
2. After checking the node that is returned by ultraTree.Nodes[5], I found that the Visible property of that node was false. This is probably due to the code that you have in the InitializeDataNode event for the UltraTree that is modifying the node visibility. I have changed the initial activation check to use the following, and everything is working as expected:
UltraTreeNode firstVisibleNode = null;
for (int i = 0; i < ultraTree1.Nodes.Count; i++) { UltraTreeNode node = ultraTree1.Nodes[i];
if (node.Visible) { firstVisibleNode = node; break; } }
if (firstVisibleNode != null) { ultraTree1.ActiveNode = firstVisibleNode; firstVisibleNode.Selected = true; }
Please let me know if you have any other questions or concerns on this matter.
See line 98
I tried attaching a zip file here but it kept giving me an error. The code in my test class is below and the designer file.
using Infragistics.Win.UltraWinTree; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Windows.Forms; namespace UltraTree_DataBinding_CS { public partial class DataTreeTest : Form { DataSet ds = new DataSet(); string oldNodeText; ToolStripMenuItem menuMove = new ToolStripMenuItem { Name = "MoveTo", Text = "Move To" }; [STAThread] static void Main() { //Load the IG isl File Infragistics.StyleLibrary.GetStyleLibrary style = new Infragistics.StyleLibrary.GetStyleLibrary(); string islFile = style.GetIsl(); Infragistics.Win.AppStyling.StyleManager.Load(islFile); Application.Run(new DataTreeTest()); } public DataTreeTest() { InitializeComponent(); LoadData(); ultraTree1.Focus(); } private void LoadData() { DataTable folders = new DataTable("Folders"); folders.Columns.Add("ID", typeof(int)); folders.Columns["ID"].AutoIncrement = true; folders.Columns["ID"].AutoIncrementSeed = 1; folders.Columns["ID"].AutoIncrementStep = 1; folders.Columns.Add("Name", typeof(string)); folders.Columns.Add("PID", typeof(int)); folders.Rows.Add(0, "Attachments", null); folders.Rows.Add(1, "A", 0); folders.Rows.Add(2, "B", 0); folders.Rows.Add(3, "C", 2); folders.Rows.Add(4, "D", 3); folders.Rows.Add(5, "E", 1); folders.Rows.Add(6, "F", 5); folders.Rows.Add(7, "G", 6); folders.Rows.Add(8, "H", 0); folders.Rows.Add(9, "I", 0); ds.Tables.Add(folders); GenerateFileMoveMenu(); DataTable files = new DataTable("Files"); files.Columns.Add("FileID", typeof(int)); files.Columns.Add("Name", typeof(string)); files.Columns.Add("FolderID", typeof(int)); files.Columns["FolderID"].ReadOnly = false; files.Rows.Add(1, "File 1", 1); files.Rows.Add(2, "File 2", 1); files.Rows.Add(3, "File 3", 3); files.Rows.Add(4, "File 4", 4); files.Rows.Add(5, "File 5", 5); files.Rows.Add(6, "File 6", 5); files.Rows.Add(7, "File 7", 1); ds.Tables.Add(files); DataRelation dr = new DataRelation("RR", folders.Columns["ID"], folders.Columns["PID"]) { Nested = true }; ds.Relations.Add(dr); ultraTree1.DataSource = folders; ultraTree1.ExpandAll(); // ****************************************************** // TEST NODE HIGHLIGHTING // ****************************************************** UltraTreeNode node = ultraTree1.Nodes[5]; // folder E ultraTree1.ActiveNode = node; node.Selected = true; ultraTree1.Focus(); // ****************************************************** // ****************************************************** } private void DeleteFolder(UltraTreeNode node) { // delete all child folders and files var descendantFolderIds = GetAllFolderDescendants(node); descendantFolderIds.Reverse(); string parentId = node.Cells["ID"].Text; foreach (var folderId in descendantFolderIds) { // delete folder files DeleteFolderFiles(folderId); // delete folder ds.Tables["Folders"].Rows.Cast<DataRow>().First(x => x.ItemArray[0].ToString() == folderId).Delete(); } // delete parent folder and files DeleteFolderFiles(parentId); ds.Tables["Folders"].Rows.Cast<DataRow>().First(x => x.ItemArray[0].ToString() == parentId).Delete(); ds.AcceptChanges(); ultraTree1.SelectedNodes.Clear(); ultraTree1.Refresh(); } private void DeleteFolderFiles(string folderKey) { var rows = ds.Tables["Files"].Rows.Cast<DataRow>().Where(x => x.ItemArray[2].ToString() == folderKey); foreach (DataRow row in rows) { row.Delete(); } ds.AcceptChanges(); } private void DeleteFiles() { if (ultraListView1.SelectedItems.Count > 0) { string folderId = ultraTree1.ActiveNode.Cells["ID"].Text; var keys = ultraListView1.SelectedItems.Select(x => x.Key).ToArray(); for (int i = 0; i < keys.Count(); i++) { var row = ds.Tables["Files"].Rows.Cast<DataRow>().First(x => x.ItemArray[0].ToString() == keys[i]); row.Delete(); var item = ultraListView1.Items[keys[i]]; ultraListView1.Items.Remove(item); } ds.AcceptChanges(); ultraTree1.ActiveNode.BringIntoView(); ultraTree1.ActiveNode = ultraTree1.Nodes[folderId]; ultraTree1.Nodes[folderId].Selected = true; ultraTree1.HideSelection = false; ultraTree1.Select(); ultraTree1.Focus(); } } private void MoveFile(string folderId) { if (ultraListView1.SelectedItems.Count > 0) { var keys = ultraListView1.SelectedItems.Select(x => x.Key).ToArray(); for (int i = 0; i < keys.Count(); i++) { var row = ds.Tables["Files"].Rows.Cast<DataRow>().First(x => x.ItemArray[0].ToString() == keys[i]); row[2] = int.Parse(folderId); } ultraTree1.SelectedNodes.Clear(); ultraTree1.ActiveNode.BringIntoView(); ultraTree1.ActiveNode = ultraTree1.Nodes[folderId]; ultraTree1.ActiveNode.Selected = true; ultraTree1.HideSelection = false; ultraTree1.Select(); ultraTree1.Focus(); } } private void GenerateFileMoveMenu() { var parentFolders = ds.Tables["Folders"].Rows.Cast<DataRow>() .Where(x => x.ItemArray[2] == null || x.ItemArray[2].ToString() == "0").ToList(); foreach (var parent in parentFolders) { var childFolders = ds.Tables["Folders"].Rows.Cast<DataRow>() .Where(x => x.ItemArray[2].ToString() == parent.ItemArray[0].ToString()).ToList(); var folder = new ToolStripMenuItem() { Name = parent[0].ToString(), Text = parent[1].ToString() }; folder.Click += new EventHandler(this.moveMenuItem_Click); if (childFolders.Count > 0) { AddChildMoveMenuItem(parent, folder); } menuMove.DropDownItems.Add(folder); } this.contextMenuStrip1.Items.Add(menuMove); } private void AddChildMoveMenuItem(DataRow parent, ToolStripMenuItem parentFolder) { var childFolders = ds.Tables["Folders"].Rows.Cast<DataRow>() .Where(x => x.ItemArray[2].ToString() == parent.ItemArray[0].ToString()).ToList(); foreach (var folder in childFolders) { var subFolders = ds.Tables["Folders"].Rows.Cast<DataRow>() .Where(x => x.ItemArray[2].ToString() == folder.ItemArray[0].ToString()).ToList(); var subFolder = new ToolStripMenuItem() { Name = folder[0].ToString(), Text = folder[1].ToString() }; subFolder.Click += new EventHandler(this.moveMenuItem_Click); if (subFolders.Count > 0) { AddChildMoveMenuItem(folder, subFolder); } parentFolder.DropDownItems.Add(subFolder); } this.contextMenuStrip1.Items.Add(menuMove); } private List<string> GetAllFolderDescendants(UltraTreeNode node) { List<UltraTreeNode> nodes = new List<UltraTreeNode>(); this.GetAllFolderDescendants(node.Nodes, nodes); return nodes.Select(x => x.Cells["ID"].Text).ToList(); } private void GetAllFolderDescendants(TreeNodesCollection nodes, List<UltraTreeNode> descendants) { foreach (UltraTreeNode node in nodes) { descendants.Add(node); if (node.HasNodes) { this.GetAllFolderDescendants(node.Nodes, descendants); } } } private void ultraTree1_InitializeDataNode(object sender, Infragistics.Win.UltraWinTree.InitializeDataNodeEventArgs e) { if (e.Node.IsRootLevelNode && !(e.Node.Cells["PID"].Value is System.DBNull)) { e.Node.Visible = false; } else { e.Node.Visible = true; } if (ultraTree1.GetNodeByKey(e.Node.Cells["ID"].Text) == null) { e.Node.Key = e.Node.Cells["ID"].Text; } } private void ultraTree1_ColumnSetGenerated(object sender, Infragistics.Win.UltraWinTree.ColumnSetGeneratedEventArgs e) { e.ColumnSet.NodeTextColumn = e.ColumnSet.Columns["Name"]; } private void ultraTree1_AfterSelect(object sender, Infragistics.Win.UltraWinTree.SelectEventArgs e) { this.ultraListView1.Items.Clear(); DataView dv = new DataView(ds.Tables["Files"]) { RowFilter = $"FolderID = {this.ultraTree1.ActiveNode.Cells["ID"].Value}" }; foreach (DataRow item in dv.ToTable().Rows) { this.ultraListView1.Items.Add(item.ItemArray[0].ToString(), item.ItemArray[1].ToString()); } } private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if(e.ClickedItem.Text == "Delete") { DeleteFiles(); } } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Delete": if (ultraTree1.ContainsFocus) { // delete tree folder(s) TreeEventManager eventManager = ultraTree1.EventManager; eventManager.SetEnabled(TreeEventIds.InitializeDataNode, false); DeleteFolder(ultraTree1.ActiveNode); eventManager.SetEnabled(TreeEventIds.InitializeDataNode, true); this.ultraListView1.Items.Clear(); ultraTree1.ActiveNode = ultraTree1.Nodes[0]; } else if (ultraListView1.ContainsFocus) { // delete selected files DeleteFiles(); } break; case "NewFolder": if (ultraTree1.ContainsFocus) { string value = ""; if (InputBox(ref value) == DialogResult.OK) { var parentId = ultraTree1.ActiveNode != null ? int.Parse(ultraTree1.ActiveNode.Cells["ID"].Text) : int.MinValue; var row = ds.Tables["Folders"].NewRow(); row[1] = value; row[2] = parentId; ultraTree1.DataSource = null; ds.Tables["Folders"].Rows.Add(row); ultraTree1.DataSource = ds.Tables["Folders"]; ultraTree1.ExpandAll(); } } break; case "Export": FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog { Description = "Select the directory that you want to export the selected files to.", ShowNewFolderButton = false, SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) }; DialogResult result = folderBrowserDialog.ShowDialog(); if (result == DialogResult.OK) { string folderName = folderBrowserDialog.SelectedPath; for (int i = 1; i < 3; i++) { File.WriteAllText(Path.Combine(folderName, $"test{i}.txt"), $"this is test {i}"); } } break; default: break; } } private DialogResult InputBox(ref string value) { Form form = new Form(); Label lbl = new Label() { Text = "Folder Name:" }; TextBox txt = new TextBox(); Button btnOk = new Button() { Text = "OK" }; Button btnCancel = new Button() { Text = "Cancel" }; btnOk.DialogResult = DialogResult.OK; btnCancel.DialogResult = DialogResult.Cancel; lbl.SetBounds(36, 36, 372, 13); lbl.AutoSize = true; txt.SetBounds(36, 86, 700, 20); btnOk.SetBounds(228, 160, 160, 60); btnCancel.SetBounds(400, 160, 160, 60); form.ClientSize = new Size(796, 307); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; form.Controls.AddRange(new Control[] { lbl, txt, btnOk, btnCancel }); form.AcceptButton = btnOk; form.CancelButton = btnCancel; DialogResult dialogResult = form.ShowDialog(); value = txt.Text; return dialogResult; } private void moveMenuItem_Click(object sender, EventArgs e) { MoveFile(((MenuItem)sender).Name); } private void ultraTree1_AfterLabelEdit(object sender, NodeEventArgs e) { if (string.IsNullOrWhiteSpace(e.TreeNode.Text)) { e.TreeNode.SetCellValue(e.TreeNode.Cells["Name"].Column, oldNodeText); } } private void ultraTree1_BeforeLabelEdit(object sender, CancelableNodeEventArgs e) { oldNodeText = e.TreeNode.Text; } } }
namespace UltraTree_DataBinding_CS { partial class DataTreeTest { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance("Collapsed", 11750610); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataTreeTest)); Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance("Expanded", 11827047); Infragistics.Win.UltraWinTree.UltraTreeNode ultraTreeNode1 = new Infragistics.Win.UltraWinTree.UltraTreeNode(); Infragistics.Win.UltraWinTree.Override _override1 = new Infragistics.Win.UltraWinTree.Override(); Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("UltraToolbar1"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool8 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Save"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("OpenFile"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool9 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Add"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Delete"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Export"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool12 = new Infragistics.Win.UltraWinToolbars.ButtonTool("NewFolder"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Delete"); Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Move"); Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("OpenFile"); Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool7 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Export"); Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool10 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Save"); Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool11 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Add"); Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool13 = new Infragistics.Win.UltraWinToolbars.ButtonTool("NewFolder"); Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance(); this.ultraTree1 = new Infragistics.Win.UltraWinTree.UltraTree(); this.ultraListView1 = new Infragistics.Win.UltraWinListView.UltraListView(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.menuDelete = new System.Windows.Forms.ToolStripMenuItem(); this.DataTreeTest_Fill_Panel = new Infragistics.Win.Misc.UltraPanel(); this._DataTreeTest_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.ultraToolbarsManager1 = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this._DataTreeTest_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._DataTreeTest_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._DataTreeTest_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); ((System.ComponentModel.ISupportInitialize)(this.ultraTree1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ultraListView1)).BeginInit(); this.contextMenuStrip1.SuspendLayout(); this.DataTreeTest_Fill_Panel.ClientArea.SuspendLayout(); this.DataTreeTest_Fill_Panel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.ultraToolbarsManager1)).BeginInit(); this.SuspendLayout(); // // ultraTree1 // this.ultraTree1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); appearance1.Image = ((object)(resources.GetObject("appearance1.Image"))); appearance2.Image = ((object)(resources.GetObject("appearance2.Image"))); this.ultraTree1.Appearances.Add(appearance1); this.ultraTree1.Appearances.Add(appearance2); this.ultraTree1.DisplayStyle = Infragistics.Win.UltraWinTree.UltraTreeDisplayStyle.Standard; this.ultraTree1.ImageTransparentColor = System.Drawing.Color.Transparent; this.ultraTree1.Location = new System.Drawing.Point(13, 12); this.ultraTree1.Name = "ultraTree1"; this.ultraTree1.NodeConnectorColor = System.Drawing.SystemColors.ControlDark; ultraTreeNode1.Text = "Attachments"; this.ultraTree1.Nodes.AddRange(new Infragistics.Win.UltraWinTree.UltraTreeNode[] { ultraTreeNode1}); _override1.AllowDelete = Infragistics.Win.DefaultableBoolean.True; appearance3.Image = ((object)(resources.GetObject("appearance3.Image"))); _override1.ExpandedNodeAppearance = appearance3; _override1.LabelEdit = Infragistics.Win.DefaultableBoolean.True; appearance4.Image = ((object)(resources.GetObject("appearance4.Image"))); _override1.NodeAppearance = appearance4; appearance5.ForeColor = System.Drawing.Color.Black; _override1.SelectedNodeAppearance = appearance5; _override1.ShowEditorButtons = Infragistics.Win.UltraWinTree.ShowEditorButtons.LabelEditOnly; _override1.UseEditor = Infragistics.Win.DefaultableBoolean.True; this.ultraTree1.Override = _override1; this.ultraTree1.Size = new System.Drawing.Size(231, 437); this.ultraTree1.TabIndex = 0; this.ultraTree1.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.Standard; this.ultraTree1.AfterLabelEdit += new Infragistics.Win.UltraWinTree.AfterNodeChangedEventHandler(this.ultraTree1_AfterLabelEdit); this.ultraTree1.AfterSelect += new Infragistics.Win.UltraWinTree.AfterNodeSelectEventHandler(this.ultraTree1_AfterSelect); this.ultraTree1.BeforeLabelEdit += new Infragistics.Win.UltraWinTree.BeforeNodeChangedEventHandler(this.ultraTree1_BeforeLabelEdit); this.ultraTree1.InitializeDataNode += new Infragistics.Win.UltraWinTree.InitializeDataNodeEventHandler(this.ultraTree1_InitializeDataNode); this.ultraTree1.ColumnSetGenerated += new Infragistics.Win.UltraWinTree.ColumnSetGeneratedEventHandler(this.ultraTree1_ColumnSetGenerated); // // ultraListView1 // this.ultraListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.ultraListView1.ContextMenuStrip = this.contextMenuStrip1; this.ultraListView1.ItemSettings.DefaultImage = ((System.Drawing.Image)(resources.GetObject("ultraListView1.ItemSettings.DefaultImage"))); this.ultraListView1.Location = new System.Drawing.Point(251, 12); this.ultraListView1.Name = "ultraListView1"; this.ultraListView1.Size = new System.Drawing.Size(399, 437); this.ultraListView1.TabIndex = 1; this.ultraListView1.Text = "ultraListView1"; this.ultraListView1.View = Infragistics.Win.UltraWinListView.UltraListViewStyle.List; // // contextMenuStrip1 // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuDelete}); this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Size = new System.Drawing.Size(108, 26); this.contextMenuStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStrip1_ItemClicked); // // menuDelete // this.menuDelete.Image = ((System.Drawing.Image)(resources.GetObject("menuDelete.Image"))); this.menuDelete.Name = "menuDelete"; this.menuDelete.Size = new System.Drawing.Size(107, 22); this.menuDelete.Text = "Delete"; // // DataTreeTest_Fill_Panel // // // DataTreeTest_Fill_Panel.ClientArea // this.DataTreeTest_Fill_Panel.ClientArea.Controls.Add(this.ultraListView1); this.DataTreeTest_Fill_Panel.ClientArea.Controls.Add(this.ultraTree1); this.DataTreeTest_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default; this.DataTreeTest_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill; this.DataTreeTest_Fill_Panel.Location = new System.Drawing.Point(0, 27); this.DataTreeTest_Fill_Panel.Name = "DataTreeTest_Fill_Panel"; this.DataTreeTest_Fill_Panel.Size = new System.Drawing.Size(662, 461); this.DataTreeTest_Fill_Panel.TabIndex = 0; // // _DataTreeTest_Toolbars_Dock_Area_Left // this._DataTreeTest_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._DataTreeTest_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._DataTreeTest_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._DataTreeTest_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._DataTreeTest_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 27); this._DataTreeTest_Toolbars_Dock_Area_Left.Name = "_DataTreeTest_Toolbars_Dock_Area_Left"; this._DataTreeTest_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 461); this._DataTreeTest_Toolbars_Dock_Area_Left.ToolbarsManager = this.ultraToolbarsManager1; // // ultraToolbarsManager1 // this.ultraToolbarsManager1.DesignerFlags = 1; this.ultraToolbarsManager1.DockWithinContainer = this; this.ultraToolbarsManager1.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form); ultraToolbar1.DockedColumn = 0; ultraToolbar1.DockedRow = 0; ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool8, buttonTool5, buttonTool9, buttonTool1, buttonTool2, buttonTool12}); ultraToolbar1.Text = "UltraToolbar1"; this.ultraToolbarsManager1.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] { ultraToolbar1}); appearance6.Image = ((object)(resources.GetObject("appearance6.Image"))); buttonTool3.SharedPropsInternal.AppearancesSmall.Appearance = appearance6; buttonTool3.SharedPropsInternal.Caption = "Delete"; appearance7.Image = ((object)(resources.GetObject("appearance7.Image"))); buttonTool4.SharedPropsInternal.AppearancesSmall.Appearance = appearance7; buttonTool4.SharedPropsInternal.Caption = "Move"; appearance8.Image = ((object)(resources.GetObject("appearance8.Image"))); buttonTool6.SharedPropsInternal.AppearancesSmall.Appearance = appearance8; buttonTool6.SharedPropsInternal.Caption = "OpenFile"; appearance9.Image = ((object)(resources.GetObject("appearance9.Image"))); buttonTool7.SharedPropsInternal.AppearancesSmall.Appearance = appearance9; buttonTool7.SharedPropsInternal.Caption = "Export"; appearance10.Image = ((object)(resources.GetObject("appearance10.Image"))); buttonTool10.SharedPropsInternal.AppearancesSmall.Appearance = appearance10; buttonTool10.SharedPropsInternal.Caption = "Save"; appearance11.Image = ((object)(resources.GetObject("appearance11.Image"))); buttonTool11.SharedPropsInternal.AppearancesSmall.Appearance = appearance11; buttonTool11.SharedPropsInternal.Caption = "Add"; appearance12.Image = ((object)(resources.GetObject("appearance12.Image"))); buttonTool13.SharedPropsInternal.AppearancesSmall.Appearance = appearance12; buttonTool13.SharedPropsInternal.Caption = "NewFolder"; this.ultraToolbarsManager1.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool3, buttonTool4, buttonTool6, buttonTool7, buttonTool10, buttonTool11, buttonTool13}); this.ultraToolbarsManager1.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.ultraToolbarsManager1_ToolClick); // // _DataTreeTest_Toolbars_Dock_Area_Right // this._DataTreeTest_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._DataTreeTest_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._DataTreeTest_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._DataTreeTest_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._DataTreeTest_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(662, 27); this._DataTreeTest_Toolbars_Dock_Area_Right.Name = "_DataTreeTest_Toolbars_Dock_Area_Right"; this._DataTreeTest_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 461); this._DataTreeTest_Toolbars_Dock_Area_Right.ToolbarsManager = this.ultraToolbarsManager1; // // _DataTreeTest_Toolbars_Dock_Area_Top // this._DataTreeTest_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._DataTreeTest_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._DataTreeTest_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._DataTreeTest_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._DataTreeTest_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._DataTreeTest_Toolbars_Dock_Area_Top.Name = "_DataTreeTest_Toolbars_Dock_Area_Top"; this._DataTreeTest_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(662, 27); this._DataTreeTest_Toolbars_Dock_Area_Top.ToolbarsManager = this.ultraToolbarsManager1; // // _DataTreeTest_Toolbars_Dock_Area_Bottom // this._DataTreeTest_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._DataTreeTest_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._DataTreeTest_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._DataTreeTest_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._DataTreeTest_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 488); this._DataTreeTest_Toolbars_Dock_Area_Bottom.Name = "_DataTreeTest_Toolbars_Dock_Area_Bottom"; this._DataTreeTest_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(662, 0); this._DataTreeTest_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.ultraToolbarsManager1; // // DataTreeTest // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(662, 488); this.Controls.Add(this.DataTreeTest_Fill_Panel); this.Controls.Add(this._DataTreeTest_Toolbars_Dock_Area_Left); this.Controls.Add(this._DataTreeTest_Toolbars_Dock_Area_Right); this.Controls.Add(this._DataTreeTest_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._DataTreeTest_Toolbars_Dock_Area_Top); this.Name = "DataTreeTest"; this.Text = "DataTreeTest"; ((System.ComponentModel.ISupportInitialize)(this.ultraTree1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ultraListView1)).EndInit(); this.contextMenuStrip1.ResumeLayout(false); this.DataTreeTest_Fill_Panel.ClientArea.ResumeLayout(false); this.DataTreeTest_Fill_Panel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.ultraToolbarsManager1)).EndInit(); this.ResumeLayout(false); } #endregion private Infragistics.Win.UltraWinTree.UltraTree ultraTree1; private Infragistics.Win.UltraWinListView.UltraListView ultraListView1; private Infragistics.Win.Misc.UltraPanel DataTreeTest_Fill_Panel; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ToolStripMenuItem menuDelete; private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ultraToolbarsManager1; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _DataTreeTest_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _DataTreeTest_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _DataTreeTest_Toolbars_Dock_Area_Bottom; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _DataTreeTest_Toolbars_Dock_Area_Top; } }
I am curious what is happening in your AfterSelect event that would be relevant the selection / activation color not working? Would it be possible for you to please modify the sample I sent you such that it demonstrates the behavior you are seeing? Alternatively, if you have an isolated sample of your own that you can provide, I can take a look at that?
Thanks, your sample worked. However, trying the same code on my form does not. I do have other event handlers on the tree, so I wonder if they are somehow interfering. I tried adding the code to ultraTree1_AfterDataNodesCollectionPopulated but that didn't help.
Here's what is interesting. I use the AfterSelect event. I added this code to it and the highlighting went away when it would usually still be there after selecting a node. This code is actually removing the highlighting in this case.
I wonder if there is something changing the focus when trying to set focus to get highlighting.