Replicating older functionality of BeginEdit

4 posts, 1 answers
  1. Alan
    Alan avatar
    8 posts
    Member since:
    Dec 2011

    Posted 10 Apr 2012 Link to this post

    I'm attempting to make the treeview in our application work as it did prior to the improvement which has it clear the current text. (i.e. I'd like the editor that gets created to have the old text in it, and that text highlighted). I've got all this down except for the highlighting.

    This needs to be done programmatically, as some nodes do not have an option to be renamed.

    What I'm doing currently is: after the treeview acquires an editor, setting the text value of that editor to the value that was the node's text. I can't, however, find an editor that has any kind of "highlight text" feature, to pass to the treeview when EditorRequired is raised. What can I do to implement this feature?
    RadTreeNode node = radTreeView1.SelectedNode;
    radTreeView1.BeginEdit();
    radTreeView1.ActiveEditor.Value = node.Text;

    Thanks in advance,
    -Alan
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Apr 2012 Link to this post

    Hello Alan,

    Thank you for writing.

    I have tested the described approach and in the EditorInitialized event I am setting the Editor.Value to the node.Text and once the editor is opened the text is highlighted. Here is a sample code:
    public Form1()
    {
        InitializeComponent();
     
        for (int i = 0; i < 10; i++)
        {
            RadTreeNode node = new RadTreeNode("Root node " + i);
            for (int j = 0; j < 10; j++)
            {
                node.Nodes.Add(new RadTreeNode("Child node " + j));
            }
            radTreeView1.Nodes.Add(node);
        }
     
        radTreeView1.AllowEdit = true;
        radTreeView1.EditorInitialized += new TreeNodeEditorInitializedEventHandler(radTreeView1_EditorInitialized);
    }
     
    void radTreeView1_EditorInitialized(object sender, TreeNodeEditorInitializedEventArgs e)
    {
        RadTreeNode node = radTreeView1.SelectedNode;
        e.Editor.Value = node.Text;
    }

    If you continue experiencing the described issue, please provide me with a code snippet of your application, which demonstrates how to reproduce it.

    I am looking forward to your reply.

    Kind regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Alan
    Alan avatar
    8 posts
    Member since:
    Dec 2011

    Posted 26 Apr 2012 Link to this post

    Stefan,

    Sorry for getting back to you so late, I know you were on pins and needles. That worked like a charm, you are the man.

    Have a good one,
    -Al
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 01 May 2012 Link to this post

    Hi Alan,

    I am glad that I could help.
     
    All the best,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top