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)
I think the problem might be that you are using the editor of the Column rather than the cell. But either way, you really dont need to get involved at the editor level in order to enter edit mode on a cell.
What you should do is just call PerformAction(EnterEditMode).
Hi. I made a little workaround for this label problem. Like mentioned, you cannot edit labels in freeform or grid. So a simple task was to simply add an event on the doubleclick of the treeview, get his selectednode and his position, show a textbox over at the position and edit the text in there. after the lost focus, hide the textbox and give back the new text to the node and voila! you've edited it...
I assume I can not use the the edit labels functions to edit labels
If the ViewStyle resolves to 'Grid' (or 'FreeForm'), and you have one level not displaying columns (Override.ShowColumns = False), then you can't edit nodes on that level. You can edit the cells in descendant levels, but the levels not displaying columns are assumed to be acting as labels. If you like you can visit http://devcenter.infragistics.com/Protected/RequestFeature.aspx and submit a request for the ability to do this.
Ok i tried using PerformAction(EnterEditMode) and as before I still can not enter a value for the label. I think the tree is not configured correcly to allow editing. Can you tell me what I have mised?