Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to selectively underline strings in RichTextBox?
    text
    copied!<p>In my program after clicking on the button - selected ListView entries should be copied to RichTextBox. ListView contains contact information, and the effect I want to accomplish is similar to the one in Oultook (when choosing contacts from contact book). Part of my code that serves this purpose looks like that:</p> <pre><code> private void toButton_Click(object sender, EventArgs e) { int start = 0; for (int i = 0; i &lt; contactsListView.SelectedItems.Count; i++) { if (contactsTextBox.TextLength != 0) contactsTextBox.Text += "; "; start = contactsTextBox.TextLength; contactsTextBox.Text += contactsListView.SelectedItems[i].Text + " " + contactsListView.SelectedItems[i].SubItems[1].Text + " [" + contactsListView.SelectedItems[i].SubItems[2].Text + "]"; contactsTextBox.Select(start, contactsTextBox.TextLength); contactsTextBox.SelectionFont = new Font(contactsTextBox.SelectionFont, FontStyle.Underline); contactsTextBox.DeselectAll(); contactsTextBox.SelectionFont = new Font(contactsTextBox.SelectionFont, FontStyle.Regular); } } </code></pre> <p>Unfortunately somehow FontStyle is inherited by entire text and everything I enter after entry from ListView is also underlined.</p> <p>So my question is - how to underline only certain text (where I have made a mistake)?</p> <p>There is similar topic on stackoverflow <a href="https://stackoverflow.com/questions/136132/better-way-of-manipulating-richtext-in-c">here</a> unfortunately in my case solution stated there will be waste of resources.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload