This is a migrated thread and some comments may be shown as answers.

Replicating older functionality of BeginEdit

3 Answers 61 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 10 Apr 2012, 08:27 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 13 Apr 2012, 11:52 AM
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 >>
0
Alan
Top achievements
Rank 1
answered on 26 Apr 2012, 02:02 PM
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
0
Stefan
Telerik team
answered on 01 May 2012, 12:45 PM
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 >>
Tags
Treeview
Asked by
Alan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Alan
Top achievements
Rank 1
Share this question
or