开发者

loading data in RichTextBox on click of a button

Using DevExpress' XtraTreeList, and in my form开发者_Python百科 there is a treelist, a RichTextBox and a button.

The goal: when the user focuses on a particular root node, and when the button is clicked, the RichTextBox should show the child nodes present in the root nodes. It needs to list the entire child nodes on the RichTextBox.

Is this possible, and how can it be done?

Is there another way with controls other than a RichTextBox?


Here is the idea (sorry, I haven't had a time to make sure this code works; I'll check it later if you need it):

private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
{
    richEditControl1.Text = GetChildNodesIntoText(e.Node);
}

string GetChildNodesIntoText(TreeListNode tln)
{
    StringBuilder sb = new StringBuilder();

    sb.AppendLine(tln.GetValue(0).ToString());


    foreach (TreeListNode n in tln.Nodes)
    {
        sb.AppendLine(GetChildNodesIntoText(n));
    }

    return sb.ToString();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜