Solved

Change text colour in textbox

Posted on 2004-08-10
7
243 Views
Last Modified: 2010-04-23
Hi,

I'd like to change the coulr of the text in my text box.  I have two buttons, and a multiline textbox.  When I click button1 text is appended to the textbox as follows:

textbox1.text &= "something"

then when button2 is clicked:

textbox1.text &= "something else"

I would like to make the text generated from button2 to be in red.  But not to change the black text generated from button1.  Is this possible?

Thanks guys.
0
Comment
Question by:jakekula
7 Comments
 
LVL 8

Expert Comment

by:razo
ID: 11770030
u could use a richtext box but when u get back the output it would be either in html or rtf so u have to extract tags to get the orginal text
a regular textbox can't handle this issue
0
 

Author Comment

by:jakekula
ID: 11770058
Oh no...  this must be a VB issue, I've seen it done in Java, but there was a fair amount of coding behind it (a whole class actually)...
0
 
LVL 19

Expert Comment

by:Desp
ID: 11770106
Textbox is not suitable for that , better use richtext.. it wont include too much code as in the case of java..

you can manipulate the colorsettings using :

RichTextBox1.SelectionStart = 7
RichTextBox1.SelectionLength = 14
RichTextBox1.SelectionColor = Color.Red  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:rohanpandya
ID: 11770283
it is not possible for the ordinary textbox but it is possible in richtextbox
Hi do following

   Dim test As String = "Hello"
            txtRich.Text = txtRich.Text + test
            txtRich.Select(2, test.Length)
            txtRich.SelectionColor = System.Drawing.Color.Red
0
 
LVL 19

Accepted Solution

by:
Desp earned 500 total points
ID: 11770318
dim s as string
s = "something"
richTextBox1.Text += s                       
richTextBox1.Select(richTextBox1.Text.Length - s.Length   , s.Length)
richTextBox1.SelectionColor = Color.Red
0
 
LVL 2

Expert Comment

by:waterhidden
ID: 11773160



Me.TextBox1.Attributes.Add("style", "color: #FF0000")

0
 
LVL 4

Expert Comment

by:y1381
ID: 11775792
you could try to create a user control inehireted from a richtextbox to do this also ..

hth

--yatharth
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now