Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a chat project and i am using a multi line textbox to show what everyone is saying but I would like to be able to bold the usernames and also make them a different color.. so basically, what is the code to format certain text in a textbox to bold and different colors.

 

Example:

Txtarrive.Text = String.Concat(Txtarrive.Text, vbNewLine & "<" & Nickname & "> " & txtSend.Text)

I need the 'Nickname' part of that line to be in bold and a different color.. like blue or something.

Posted

ok, i replaced it with a rich textbox.. but im not sure how to get just the Nickname part in bold and a different color.. here is the code for bold: New Font("Arial", 12, FontStyle.Bold)

 

I just need to get only Nickname bold, not the whole richtextbox.

Posted
ok, i replaced it with a rich textbox.. but im not sure how to get just the Nickname part in bold and a different color.. here is the code for bold: New Font("Arial", 12, FontStyle.Bold)

 

I just need to get only Nickname bold, not the whole richtextbox.

 

I haven't used this control in .NET but I would venture a guess and say something like this:

//set the bold for the username
New Font("Arial",12,FontStyle.Bold);
Text1.text +="\r\n" + strUserName; 
//set to normal for teh rest of the text
New Font("Arial",12,FontStyle.Regular);
Text1.text +=": " + strMessage;

-Sean
  • Leaders
Posted

Find NickName in the textbox, and highlight it (you can do this with IndexOf, RTB.SelectionStart and RTB.SelectionLength

 

From here, you set the RTB.SelectedFont to a New Font("Arial", 12, FontStyle.Bold) :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted

ok, i added this and it isn't working:

       textMessages.SelectionStart = textNick.Text
       textMessages.SelectionLength = textNick.Text
       textMessages.SelectionFont = New Font("Tahoma", 9, FontStyle.Bold)

  • Leaders
Posted

You need to use IndexOf to find the location of the textNick.Text. SelectionStart and selectionlength are integers... you should not assign strings to them.

:)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...