treeview - C# Cursor/ Caret Not display when Append text in Richtextbox -
I am new to programming, I am applying C # windows form, if you select tree node, Adds:
Qs1: The carrot node for me has not been displayed after selecting. Q2: Create a display-like display, where the word beginning with // should be green (comment).
Thanks
if (treeView1.SelectedNode.Name == "node1") {this.richtextbox1. Selected text + = "My text for node 1" + Environment New Rich Textbox 1 Focus (); } And if (tree view 1. select node .name == "node 2") {this.richtextbox1.SelectedText + = "my text for node 2" + environment New Rich Textbox 1 Focus (); }
You are asking two questions related to RichTextBox . The preferred form on stack overflow is that you will probably get more responses with more focused questions. It is being said:
-
According to the documentation for the law:
So you need to do this first.
In addition, as a general rule, you should never modify the already existing or + = , because it will use any and all RTF formatting Instead, to insert text, you should set the selection to the desired location, with length zero, and insert it there. Thus: Public Focus Focus and Appendtoke Text (This RichTextBox Rich Textbox, String Text) {Action Append = () = & gt; {RichTextBox.Focus (); Var start = richTextBox.SelectionStart; Var length = Rich textbox. Election length; Var insertAt = start + length; RichTextBox.Select (Dalatat, 0); Richtextbox.SelectedText = text; }; If RichTextBox.InvokeRequired (RichTextBox.BeginInvoke); Second attachment (); } In addition, you instead of \ n New Line should be used. -
Display a question like "how to do" as editor, where the word should begin with the word "(comment) in green" is very common. Try to break it in different issues and ask questions for those you can not understand yourself about. To get you started, see this question here: However, you can not set your exact UI requirements.
Comments
Post a Comment