Lanc1988 Posted December 10, 2004 Posted December 10, 2004 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. Quote
coldfusion244 Posted December 10, 2004 Posted December 10, 2004 Use a richtextbox, not a regular one. RichTextBox Quote -Sean
Lanc1988 Posted December 11, 2004 Author Posted December 11, 2004 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. Quote
coldfusion244 Posted December 11, 2004 Posted December 11, 2004 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; Quote -Sean
Leaders Iceplug Posted December 11, 2004 Leaders Posted December 11, 2004 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) :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Lanc1988 Posted December 12, 2004 Author Posted December 12, 2004 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) Quote
Leaders Iceplug Posted December 15, 2004 Leaders Posted December 15, 2004 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. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.