Hi, I am having problems getting items on UltraTree to enter edit moode.
I have set
m_ultraTree.DataSource = new AList();
this gives me a two level tree, adding and removing items to the Alist instance causes items to appear on the Tree.
Now I wish to be able to edit the Name (label) of each instance of AClass on the tree and have the underleying AClass item. So I have done the following
m_ultraTree.NodeLevelOverrides.Add(_override1);
_override1.ShowColumns = DefaultableBoolean.False;
_override1.UseEditor = DefaultableBoolean.True;
_override1.LabelEdit = DefaultableBoolean.True
As a test I have added the following as a DoubleClick event handeler
private void m_ultraTree_DoubleClick(object sender, EventArgs e)
{
UltraTreeNode node = m_portsTree.SelectedNodes[0];
node.BeginEdit();
node.EditorResolved.Value = "change";
node.EndEdit(false);
}
This method fails on node.EditorResolved.Value = "change" with the exception "Can't access the 'Value' property when not in edit mode".
Ok thinking I need to edit as cell instead I tried
private void m_portsTree_DoubleClick(object sender, EventArgs e)
UltraTreeNodeColumn column = node.DataColumnSetResolved.Columns["Name"];
column.AllowCellEdit = AllowCellEdit.Full;
bool c = node.BeginCellEdit(column);
column.EditorResolved.Value = "fff";
node.EndCellEdit(true);
As before I get an exception and c is false.
How can I get this code to work.
FYI there is the Alist and AClass.
public class AList : BindingList<AClass>
public class AClass: INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private string m_name;
private readonly BindingList<string> m_bList;
public AClass (string name)
m_name = name;
m_bList = new BindingList<string> ();
public string Name
get { return m_name; }
set
m_name = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
public BindingList<string> Blist
get { return m_bList; }
If you want to change the value of a cell, you don't need to mess around with editors. You can simply call SetCellValue on the node or set the Value property of the cell.
Thanks for the relpy Mike, but I think you missed what i am trying to do. I want to change the value of the nodes lable using the Editor (i.e have the user enter the value on the UltraTree Control) I was, as you say, messing :0) around with editors just as a way of testing wheater i could activate an editor on the node; i could not. Clicking the node, pressing F2 failed to activate an editor so i tried to do it programaticaly.
So my questions still stand. Why is the node not activating editor? Should I be using a Label or a cell editor?
At the end of the day all I want is to allow users to:
1) edit the name of the first level nodes
2) enter the value of the name of the node when it is added (for which i will need to call BeginEdit or BeginCellEdit)