Inserting at top of richtextbox
c#, richtextbox
Solution
`startFinshBox.Text` is a string, which is an immutable type in C#. `string.Insert()` will return the modified string as a result, but it your code you discard it. To make it work, you have to change the code to:
private void execute_Click(object sender, EventArgs e){
startFinshBox.Text = "Start Time: " + printTime()+"";
startFinshBox.Text = startFinshBox.Text.Insert(0,printTime()+": Retrieving Results...\n");
}
Problem
Whats wrong with this code? Trying to get my text to insert at the beginning of the textbox rather than at the bottom. ``` private void execute_Click(object sender, EventArgs e){ startFinshBox.Text = "Start Time: " + printTime()+""; startFinshBox.Text.Insert(0,printTime()+": Retrieving Results...\n"); } ``` But it will not insert the second line into the rtb. I have tried with startFinishBox.SelectionStart = 0 as well, and it made no difference. Am I missing something else? Thanks, Psy