c# - How to selectively underline strings in RichTextBox? -


After clicking on the button in my program - the selected list view entries should be copied to the rich textbox. The list view contains contact information, and the effect I want to do is similar to the Altcat (when selecting contacts from the contact book). A part of my code that serves this purpose looks like this:

  Private zero broken buttons (Object Sender, EventEurge E) {int start = 0; (Int i = 0; i & lt; contactListView.SelectedItems.Count; i ++) {if (contactsTextBox.TextLength! = 0) contactsTextbox. Text + = ";"; Start = contactsTextBox.TextLength; Contacts tab box. Text + = contactlistview Selected ITems [i]. Text + "+ + Contact List. Selected items [i] .SubItems [1]. Text +" [ "+ Contact Listwu. Selected items [i] .SubItems [2]. Text +"] "; Snprktekstboks. SelectTextBox.DeselectAll (); ContactsTextBox.SelectionFont = New Font (contactsTextBox.SelectionFont, FontStyle.Regular); Unfortunately, select (Start, Contact, Textbox, Textile); ContactsTextBox.SelectionFont = New Font (contactsTextBox.SelectionFont, FontStyle.Underline); ContactsTextBox.DeselectAll Either way, FontStyle is inherited by the complete text and whatever I rate after entry from ListView H is has been outlined her.  

So my question is - text (where I made a mistake)?

The solution in my case unfortunately stack overflow There is a similar topic, there will be a waste of resources.

Instead, try it:

  int start = 0; for (int i = 0; i & lt; contactListView.SelectedItems.Count; i ++) {if (contactsTextBox.TextLength! = 0) Snprcontekstboks. Text + = ";"; Start = contactsTextBox.TextLength; Contacts tab box. Text + = contactlistview Selected ITems [i]. Text + "+ + Contact List. Selected items [i] .SubItems [1]. Text +" [ "+ Contact Listwu. Selected items [i] .SubItems [2]. Text +"] ";} This .contactsTextBox.Text + = ""; This.contactsTextBox.SelectionStart = 0; This.contactsTextBox.SelectionLength = this.contactsTextBox.Text.Length-1; ContactsTextBox.SelectionFont = new Font (contactsTextBox.SelectionFont, FontStyle.Underline); This .contactsTextBox.SelectionLength = 0;  

the total hack, but basically, if you select the text after it there, but it does not select all (why That I add additional "") and then select the SELECT option It is the desired effect.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -