Solved

Change text colour in textbox

Posted on 2004-08-10
7
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

617 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