trouble getting the selected text of Systreeview32 control

Class library usage, coding and language questions.
Posts: 4
Joined: Tue Sep 18, 2007 3:45 pm
Location: USA

trouble getting the selected text of Systreeview32 control

Post by creynolds » Fri Mar 28, 2008 5:38 pm

I'm having trouble getting the selected text of a treeview control using the following code:

form = Application.FindForm("form title", SearchMatchMode.MatchExact, "AfxFrameOrView70u", false, 5000);

control = form.FindControlId(5858);
TreeView treeview = form.FindTreeView(5858);
string text = treeview.SelectedText;

The text is always null. I have had trouble with this control in the past and have had to walk the tree with keystrokes to populate all of the nodes, but now I can't get any info on it. ItemCounts, selected text and rootItems are all empty.

Any help would be great

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Fri Mar 28, 2008 6:21 pm

Can you please try the following code:
(Element approach)

Code: Select all

Element[] treeItems = treeView.Element.FindChildren(Role.OutlineItem);
foreach (Element item in treeItems)
    Console.WriteLine("Item = {0} ", item.Name);
    if ((item.State & State.Selected) != 0)
        Console.WriteLine("  SelectedItem= {0} ", item.Name);
Ranorex Team