Hi there,
I have some difficulties to use editors in an ultra tree. I would like to create a tree just like the PropertyGrid, so I would like to have different data type in the cells (String, Integer, Boolean, Color, Font etc..)
I succedded with the string, the font, the combo but I have problems with the colorpicker (I have the color but it's not editable) and also with the CheckEditor (I can't check/uncheck)
Remark: If I set DataType=typeof(Color) for a colum it works well. But since I want to have different type in the cells I can't do that.
Thanks for your help.
Here is my sample code:
-------------------------------------------------------------
using System;using System.Drawing;using System.Windows.Forms;using Infragistics.Win;using Infragistics.Win.UltraWinTree;using Infragistics.Win.UltraWinEditors;
namespace InfragisticEditors{ public partial class Form1 : Form { private UltraTreeNodeColumn _colName; private UltraTreeNodeColumn _colValue;
public Form1() { InitializeComponent();
InitTree(); }
private void InitTree() { // Clear nodes: this.ultraTree1.Nodes.Clear();
// set outlook view style: this.ultraTree1.ViewStyle = ViewStyle.OutlookExpress; this.ultraTree1.Indent = 10;
// Editable cells: this.ultraTree1.Override.CellClickAction = CellClickAction.EditCell; // Only allow one node to be selected at a time this.ultraTree1.Override.SelectionType = SelectType.Single;
// Use single-pixel borders of 'Control' color for the cells this.ultraTree1.ColumnSettings.BorderStyleCell = UIElementBorderStyle.Solid; this.ultraTree1.ColumnSettings.CellAppearance.BorderColor = SystemColors.Control;
// Hide the headers: this.ultraTree1.ColumnSettings.LabelPosition = NodeLayoutLabelPosition.None;
// Add colums: UltraTreeColumnSet rootColumnSet = this.ultraTree1.ColumnSettings.RootColumnSet; _colName = rootColumnSet.Columns.Add("Name"); _colName.DataType = typeof(string); _colName.LayoutInfo.PreferredCellSize = new Size(this.ultraTree1.Width / 2, 0);
_colValue = rootColumnSet.Columns.Add("Value"); _colValue.DataType = typeof(object); _colValue.LayoutInfo.PreferredCellSize = new Size(this.ultraTree1.Width / 2, 0); _colValue.AllowCellEdit = AllowCellEdit.Full; }
private void Form1_Load(object sender, EventArgs e) { // Add a text node: String str = "Hello world"; UltraTreeNode node1 = this.ultraTree1.Nodes.Add(null, ""); node1.SetCellValue(_colName, "String"); node1.SetCellValue(_colValue, str);
// Add a color: Color color = Color.FromArgb(255, 0, 0); UltraTreeNode node2 = this.ultraTree1.Nodes.Add(null, ""); node2.Cells[_colValue].Editor = new ColorPickerEditor(); node2.SetCellValue(_colName, "Color"); node2.SetCellValue(_colValue, color);
// Add a combo UltraComboEditor editorControl = new UltraComboEditor(); UltraTreeNode node3 = this.ultraTree1.Nodes.Add(null, ""); editorControl.Items.Add("True"); editorControl.Items.Add("False"); editorControl.DropDownStyle = DropDownStyle.DropDownList; node3.Cells[_colValue].EditorControl = editorControl; node3.SetCellValue(_colName, "Combobox"); node3.SetCellValue(_colValue, false);
// Add a checkbox: UltraTreeNode node4 = this.ultraTree1.Nodes.Add(null, ""); node4.Cells[_colValue].Editor = new CheckEditor(); node4.SetCellValue(_colName, "Checkbox"); node4.SetCellValue(_colValue, false);
// Add a collection UltraTreeNode node5 = this.ultraTree1.Nodes.Add(null, ""); EditorWithText textEditor = new EditorWithText(); node5.Cells[_colValue].Editor = textEditor; EditorButton editorButton = new EditorButton("ellipsis"); editorButton.Text = "..."; //editorButton.Click += new Infragistics.Win.UltraWinEditors.EditorButtonEventHandler(editorButton_Click); textEditor.ButtonsRight.Add(editorButton); node5.Cells[_colValue].AllowEdit = AllowCellEdit.ReadOnly; node5.SetCellValue(_colName, "Button"); node5.SetCellValue(_colValue, "(Collection)");
// Add a font: Font font = new Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); UltraTreeNode node6 = this.ultraTree1.Nodes.Add(null, ""); node6.Cells[_colValue].Editor = new FontNameEditor(); node6.SetCellValue(_colName, "Font"); node6.SetCellValue(_colValue, font); } }}
Thank you Mike and team for replying so quickly.
I tried so many ways before but could not succeed; now finally it is working, I am happy to see my particular node(s) getting bold in tree.
Hi,
The problem with this code is that you are walking up to the control. To change the appearance of a single node, you need to use the properties of that node.
nodeAtPoint.Override.NodeAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
I have similar problem. I want to make a particular node of tree as bold (or say of different color).
I have tried some thing below but this code is reflecting on the whole tree. All nodes become bold.
I only want my nodeAtPoint text to get bold.
//UltraTreeNode nodeAtPoint;
// try1:
//nodeAtPoint.UIElement.Control.Font = new Font("Arial", 20.0f, FontStyle.Bold);
//try 2:
//nodeAtPoint.Control.Font = new Font("Arial", 20.0f, FontStyle.Bold);
e.g in below UltraTree only B node is bold.
-A
-- B
----C
-D
Actuall, what happens is that merely assigning an impelmentation to the DataFilter property lifts the restriction; we have to make the assumption that the implmenetaiton is going to work, so we automatically return true from the editor's CanEditType method when wesee that the DataFilter property is set.
I could be mistaken, but I think unconditionally returning null might prevent a value from ever getting back to the cell.
Hi thanks for your response. I started to look at the IEditorDataFilter and when I use the code in my first post and I modify like this (for the Color picker):
node2.Cells[_colValue].Editor = new ColorPickerEditor(); node2.Cells[_colValue].Editor.DataFilter = new ColorPickerEditorFilter();
And I created a class like this:
class ColorPickerEditorFilter : Infragistics.Win.IEditorDataFilter { object Infragistics.Win.IEditorDataFilter.Convert(Infragistics.Win.EditorDataFilterConvertArgs args) { return null; } }
As you can see the Convert method returns null and it works !! I can use the Color picker in my cell, edit it etc.. And the same for the check box.
It's a strange behaviour, isn't it ?
Thanks anyway :)