Hi,
Attached is a screenshot that explain what I am trying to accomplish. Basically I have a need to have different column set for siblings (that share a the same parent node). The below code is very close but I want to remove the duplicate header for the second node.
Huge thanks for any helps you can provide.
using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinTree; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace BatchTreeControl { public partial class Form1 : Form { private ValueList _filtersValueList; private ValueList _batchValueList; private UltraTreeColumnSet _fixBatchColumnSet; private UltraTreeColumnSet _fixFilterColumnSet; private UltraTreeColumnSet _timeBatchColumnSet; private UltraTreeColumnSet _timeFilterColumnSet; private UltraTreeColumnSet _deleteByColumnSet; private UltraCheckEditor _checkEditor; private UltraComboEditor _comboEditor; public Form1() { InitializeComponent(); InitializeData(); InitializeUI(); } private void InitializeData() { _batchValueList = new ValueList(); _batchValueList.ValueListItems.Add("Batch", "Batch"); _batchValueList.ValueListItems.Add("PlateID", "Plate ID"); _batchValueList.ValueListItems.Add("JobCode", "Job Code"); _batchValueList.ValueListItems.Add("BarCode", "Bar Code"); _filtersValueList = new ValueList(); _filtersValueList.ValueListItems.Add("CompoundType", "Compound Type"); _filtersValueList.ValueListItems.Add("Batch", "Batch"); _filtersValueList.ValueListItems.Add("JobCode", "Job Code"); _filtersValueList.ValueListItems.Add("TaskCode", "Task Code"); _filtersValueList.ValueListItems.Add("AnalysisName", "Analysis Name"); _filtersValueList.ValueListItems.Add("CalibrationStrategy", "Calibration Strategy"); _checkEditor = new UltraCheckEditor(); _checkEditor.CheckAlign = ContentAlignment.MiddleLeft; _comboEditor = new UltraComboEditor(); _comboEditor.DropDownStyle = DropDownStyle.DropDownList; _fixBatchColumnSet = new UltraTreeColumnSet(); _fixBatchColumnSet.Columns.Add("Active"); _fixBatchColumnSet.Columns.Add("Name"); _fixBatchColumnSet.Columns.Add("Group By"); _fixBatchColumnSet.Columns.Add("Expected Count"); _fixBatchColumnSet.Columns["Active"].DataType = typeof(Boolean); _fixBatchColumnSet.Columns["Active"].AllowCellEdit = AllowCellEdit.Full; _fixBatchColumnSet.Columns["Active"].EditorComponent = _checkEditor; _fixBatchColumnSet.Columns["Active"].HeaderAppearance.TextHAlign = HAlign.Left; _fixBatchColumnSet.Columns["Group By"].EditorComponent = _comboEditor; _fixBatchColumnSet.Columns["Group By"].DataType = typeof(String); _fixBatchColumnSet.Columns["Group By"].AllowCellEdit = AllowCellEdit.Full; _fixBatchColumnSet.Columns["Group By"].ValueList = _batchValueList; _fixBatchColumnSet.Columns["Group By"].HeaderAppearance.TextHAlign = HAlign.Left; _fixBatchColumnSet.Columns["Name"].LayoutInfo.PreferredCellSize = new System.Drawing.Size(0, this.ultraTree1.Font.Height + 5); _fixBatchColumnSet.Columns["Name"].AllowCellEdit = AllowCellEdit.Full; _fixBatchColumnSet.Columns["Name"].HeaderAppearance.TextHAlign = HAlign.Left; _fixBatchColumnSet.Columns["Expected Count"].AllowCellEdit = AllowCellEdit.Full; _fixBatchColumnSet.Columns["Expected Count"].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right; _fixBatchColumnSet.Columns["Expected Count"].HeaderAppearance.TextHAlign = HAlign.Left; _fixFilterColumnSet = new UltraTreeColumnSet(); _fixFilterColumnSet.Columns.Add("Filter By"); _fixFilterColumnSet.Columns.Add("Value"); _fixFilterColumnSet.Columns.Add("Expected Count"); _fixFilterColumnSet.Columns["Filter By"].EditorComponent = _comboEditor; _fixFilterColumnSet.Columns["Filter By"].DataType = typeof(String); _fixFilterColumnSet.Columns["Filter By"].AllowCellEdit = AllowCellEdit.Full; _fixFilterColumnSet.Columns["Filter By"].ValueList = _filtersValueList; _fixFilterColumnSet.Columns["Filter By"].LayoutInfo.PreferredCellSize = new System.Drawing.Size(0, this.ultraTree1.Font.Height + 3); _fixFilterColumnSet.Columns["Filter By"].HeaderAppearance.TextHAlign = HAlign.Left; _fixFilterColumnSet.Columns["Value"].AllowCellEdit = AllowCellEdit.Full; _fixFilterColumnSet.Columns["Value"].HeaderAppearance.TextHAlign = HAlign.Left; _fixFilterColumnSet.Columns["Expected Count"].AllowCellEdit = AllowCellEdit.Full; _fixFilterColumnSet.Columns["Expected Count"].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right; _fixFilterColumnSet.Columns["Expected Count"].HeaderAppearance.TextHAlign = HAlign.Left; _timeBatchColumnSet = new UltraTreeColumnSet(); _timeBatchColumnSet.Columns.Add("Active"); _timeBatchColumnSet.Columns.Add("Name"); _timeBatchColumnSet.Columns.Add("Group By"); _timeBatchColumnSet.Columns.Add("Process After"); _timeBatchColumnSet.Columns["Active"].DataType = typeof(Boolean); _timeBatchColumnSet.Columns["Active"].AllowCellEdit = AllowCellEdit.Full; _timeBatchColumnSet.Columns["Active"].EditorComponent = _checkEditor; _timeBatchColumnSet.Columns["Active"].HeaderAppearance.TextHAlign = HAlign.Left; _timeBatchColumnSet.Columns["Group By"].EditorComponent = _comboEditor; _timeBatchColumnSet.Columns["Group By"].DataType = typeof(String); _timeBatchColumnSet.Columns["Group By"].AllowCellEdit = AllowCellEdit.Full; _timeBatchColumnSet.Columns["Group By"].ValueList = _batchValueList; _timeBatchColumnSet.Columns["Group By"].HeaderAppearance.TextHAlign = HAlign.Left; _timeBatchColumnSet.Columns["Name"].LayoutInfo.PreferredCellSize = new System.Drawing.Size(0, this.ultraTree1.Font.Height + 5); _timeBatchColumnSet.Columns["Name"].AllowCellEdit = AllowCellEdit.Full; _timeBatchColumnSet.Columns["Name"].HeaderAppearance.TextHAlign = HAlign.Left; _timeBatchColumnSet.Columns["Process After"].AllowCellEdit = AllowCellEdit.Full; _timeBatchColumnSet.Columns["Process After"].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right; _timeBatchColumnSet.Columns["Process After"].HeaderAppearance.TextHAlign = HAlign.Left; _timeFilterColumnSet = new UltraTreeColumnSet(); _timeFilterColumnSet.Columns.Add("Filter By"); _timeFilterColumnSet.Columns.Add("Value"); _timeFilterColumnSet.Columns.Add("Expected Count"); _timeFilterColumnSet.Columns["Filter By"].EditorComponent = _comboEditor; _timeFilterColumnSet.Columns["Filter By"].DataType = typeof(String); _timeFilterColumnSet.Columns["Filter By"].AllowCellEdit = AllowCellEdit.Full; _timeFilterColumnSet.Columns["Filter By"].ValueList = _filtersValueList; _timeFilterColumnSet.Columns["Filter By"].LayoutInfo.PreferredCellSize = new System.Drawing.Size(0, this.ultraTree1.Font.Height + 3); _timeFilterColumnSet.Columns["Filter By"].HeaderAppearance.TextHAlign = HAlign.Left; _timeFilterColumnSet.Columns["Value"].AllowCellEdit = AllowCellEdit.Full; _timeFilterColumnSet.Columns["Value"].HeaderAppearance.TextHAlign = HAlign.Left; _timeFilterColumnSet.Columns["Expected Count"].AllowCellEdit = AllowCellEdit.Full; _timeFilterColumnSet.Columns["Expected Count"].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right; _timeFilterColumnSet.Columns["Expected Count"].HeaderAppearance.TextHAlign = HAlign.Left; _deleteByColumnSet = new UltraTreeColumnSet(); _deleteByColumnSet.Columns.Add("Remove Duplicates By"); _deleteByColumnSet.Columns["Remove Duplicates By"].EditorComponent = _comboEditor; _deleteByColumnSet.Columns["Remove Duplicates By"].DataType = typeof(String); _deleteByColumnSet.Columns["Remove Duplicates By"].AllowCellEdit = AllowCellEdit.Full; _deleteByColumnSet.Columns["Remove Duplicates By"].ValueList = _batchValueList; _deleteByColumnSet.Columns["Remove Duplicates By"].HeaderAppearance.TextHAlign = HAlign.Left; } private UltraTreeNode AddFixBatchNode(UltraTreeNode parentNode, String batchName, String defaultGroupByValue, Int32 Count) { parentNode.Nodes.Override.ColumnSet = _fixBatchColumnSet; String key = Guid.NewGuid().ToString(); UltraTreeNode node = parentNode.Nodes.Add(key, key); node.Nodes.Override.ColumnSet = _fixBatchColumnSet; node.Cells["Active"].Value = true; node.Cells["Name"].Value = batchName; node.Cells["Group By"].Value = defaultGroupByValue; node.Cells["Expected Count"].Value = Count.ToString(); return node; } private UltraTreeNode AddFixFilterNode(UltraTreeNode parentNode, String attributeName, String value, Int32 Count) { parentNode.Nodes.Override.ColumnSet = _fixFilterColumnSet; String key = Guid.NewGuid().ToString(); UltraTreeNode node = parentNode.Nodes.Add(key, key); node.Nodes.Override.ColumnSet = _fixFilterColumnSet; node.Cells["Filter By"].Value = attributeName; node.Cells["Value"].Value = value; node.Cells["Expected Count"].Value = Count.ToString(); return node; } private UltraTreeNode AddTimeBatchNode(UltraTreeNode parentNode, String batchName, Int32 minutes) { parentNode.Nodes.Override.ColumnSet = _timeBatchColumnSet; String key = Guid.NewGuid().ToString(); UltraTreeNode node = parentNode.Nodes.Add(key, key); node.Nodes.Override.ColumnSet = _timeBatchColumnSet; node.Cells["Active"].Value = true; node.Cells["Name"].Value = batchName; node.Cells["Group By"].Value = "Batch"; node.Cells["Process After"].Value = minutes.ToString(); return node; } private UltraTreeNode AddTimeFilterNode(UltraTreeNode parentNode, String attributeName, String value, Int32 Count) { parentNode.Nodes.Override.ColumnSet = _timeFilterColumnSet; String key = Guid.NewGuid().ToString(); UltraTreeNode node = parentNode.Nodes.Add(key, key); node.Nodes.Override.ColumnSet = _timeFilterColumnSet; node.Cells["Filter By"].Value = attributeName; node.Cells["Value"].Value = value; node.Cells["Expected Count"].Value = Count.ToString(); return node; } private UltraTreeNode AddRemoveByNode(UltraTreeNode parentNode, String defaultGroupByValue) { //parentNode.Nodes.Override.ColumnSet = _deleteByColumnSet; String key = Guid.NewGuid().ToString(); UltraTreeNode node = parentNode.Nodes.Add(key, key); //node.Nodes.Override.ColumnSet = _deleteByColumnSet; node.Override.ColumnSet = _deleteByColumnSet; node.Cells["Remove Duplicates By"].Value = defaultGroupByValue; return node; } private void InitializeUI() { this.ultraTree1.AfterExpand += ultraTree1_AfterExpand; Infragistics.Win.AppStyling.StyleManager.Load(@"StyleSet.isl", false, "mystyle"); //@"C:\Users\Public\Documents\Infragistics\NetAdvantage 2011.2\Windows Forms\Samples\Data\StyleLibrary\IG.isl", false, "mystyle"); //Infragistics.Win.AppStyling.StyleManager.Load(@"C:\Users\Public\Documents\Infragistics\NetAdvantage 2011.2\Windows Forms\Samples\Data\StyleLibrary\IG.isl", false, "mystyle"); this.ultraTree1.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.FreeForm; this.ultraTree1.StyleLibraryName = @"mystyle"; this.ultraTree1.Override.SelectionType = SelectType.Single; this.ultraTree1.Override.CellClickAction = CellClickAction.EditCell; this.ultraTree1.Override.UseEditor = DefaultableBoolean.True; this.ultraTree1.ScrollBounds = ScrollBounds.ScrollToFill; this.ultraTree1.ColumnSettings.AutoFitColumns = AutoFitColumns.ResizeAllColumns; this.ultraTree1.ColumnSettings.ColumnAutoSizeMode = ColumnAutoSizeMode.AllNodes; UltraTreeNode fixQuantityBatchesNode = this.ultraTree1.Nodes.Add(null, "Fix Count Batches (3)"); UltraTreeNode timeTriggeredBatches = this.ultraTree1.Nodes.Add(null, "Time Triggered Batches (1)"); fixQuantityBatchesNode.Selected = true; UltraTreeNode node1 = AddFixBatchNode(fixQuantityBatchesNode, "LogD", "Batch", 20); UltraTreeNode node2 = AddFixBatchNode(fixQuantityBatchesNode, "Solubility", "Batch", 20); AddFixFilterNode(node1, "CompoundType", "BLANK", 5); AddFixFilterNode(node1, "CompoundType", "STD", 5); AddFixFilterNode(node1, "CompoundType", "SAMPLE", 10); AddFixFilterNode(node1, "CalibrationStrategy", "LogD", 0); AddFixFilterNode(node2, "CompoundType", "BLANK", 5); AddFixFilterNode(node2, "CompoundType", "STD", 5); AddFixFilterNode(node2, "CompoundType", "SAMPLE", 10); AddFixFilterNode(node2, "CalibrationStrategy", "Solubility", 0); // Sample batch UltraTreeNode ESIBatchNode = AddFixBatchNode(fixQuantityBatchesNode, "ESI Batch", "BarCode", 6); AddFixFilterNode(ESIBatchNode, "AnalysisName", "PRE-QC", 0); _deleteByColumnSet.Key = "ABC"; ESIBatchNode.Nodes.Override.ColumnSet.ColumnSettings.ColumnSets.Add(_deleteByColumnSet); AddRemoveByNode(ESIBatchNode, "BarCode"); AddRemoveByNode(ESIBatchNode, "JobCode"); // Time based UltraTreeNode node3 = AddTimeBatchNode(timeTriggeredBatches, "A time based batch", 5); AddTimeFilterNode(node3, "CompoundType", "BLANK", 5); AddTimeFilterNode(node3, "CompoundType", "STD", 5); AddTimeFilterNode(node3, "CompoundType", "SAMPLE", 10); this.ultraTree1.Select(); this.ultraTree1.ExpandAll(ExpandAllType.Always); } void ultraTree1_AfterExpand(object sender, NodeEventArgs e) { foreach (UltraTreeNodeCell col in e.TreeNode.Cells) { col.Column.PerformAutoResize(); } } private void ultraTree1_CellValueChanged(object sender, CellValueChangedEventArgs e) { if (e.Column.TextResolved.Equals("Active", StringComparison.CurrentCultureIgnoreCase)) { Boolean currentValue = Boolean.Parse(e.CurrentValue.ToString()); // Disable / Enable child nodes (filters) foreach(var node in e.Node.Nodes) { node.Enabled = currentValue; } // Disable / Enable the node columns for (int i = 1; i < e.Node.Cells.Count; i++) { e.Node.Cells[i].AllowEdit = (!currentValue) ? AllowCellEdit.ReadOnly : AllowCellEdit.Full; } } } } }
Thanks!
Hello Joseph,
Thank you for posting in our forum.
Right now this is not supported scenario. You may set the column set for all child nodes or per child node. When you set the column set to all child nodes the child nodes are showing with one column header. When you set a column set to each child node, each child node has its own column header. The tree does not recognize if the column sets are equal and does not merge the child nodes if the column sets are equal. After working on this the idea to be able to merge child nodes with equal column sets has been determined to be a new product idea. You can suggest new product ideas for future versions (or vote for existing ones) at <http://ideas.infragistics.com>.
There are many benefits to submitting a product idea:
Direct communication with our product management team regarding your product idea.
Notifications whenever new information regarding your idea becomes available.
Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
Allow you to shape the future of our products by requesting new controls and products altogether.
You and other developers can discuss existing product ideas with members of our Product Management team.
Steps to create your idea:
Log into the Infragistics Product Idea site at http://ideas.infragistics.com (creating a new login if needed).
Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
Add your product idea and be sure to be specific and provide as much detail as possible.
Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
Include a link to this thread in your idea so product management will be able to look back at this case.
The Product Idea site puts you in the driver’s seat and allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Thank you for contacting Infragistics.