Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
465
Data binding and Label editing problem
posted

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)

    {

        UltraTreeNode node = m_portsTree.SelectedNodes[0];

        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; }

        }

    }

 

Parents Reply Children