473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Different colored lines in the same textbox

How do i write lines with different colors in a textbox?
I've tried using the forecolor property and it just takes the last
color.
eg.
TextBox1.ForeColor = Color.Red
TextBox1.Text = "test" & " "
TextBox1.ForeColor = Color.Purple
TextBox1.Text &= "test2"

It prints both test and test2 in purple

Mar 23 '06 #1
2 3471

"None" <sh**********@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
How do i write lines with different colors in a textbox?
I've tried using the forecolor property and it just takes the last
color.
eg.
TextBox1.ForeColor = Color.Red
TextBox1.Text = "test" & " "
TextBox1.ForeColor = Color.Purple
TextBox1.Text &= "test2"

It prints both test and test2 in purple


I don't believe this is possible in a default textbox. There are 2 options
I believe you have..

1. use an RTF box instead.
2. Custom Draw your textbox. This would be more work but I think it would
allow you to set the different colors using the graphics.drawxxxx methods.

jjardine
Mar 23 '06 #2
"None" <sh**********@gmail.com> schrieb:
How do i write lines with different colors in a textbox?
I've tried using the forecolor property and it just takes the last
color.
eg.
TextBox1.ForeColor = Color.Red
TextBox1.Text = "test" & " "
TextBox1.ForeColor = Color.Purple
TextBox1.Text &= "test2"

It prints both test and test2 in purple


You may want to use the RichTextBox control instead of the common textbox.
The richtextbox' 'SelectionColor' property can be used to change the color
of the selected text.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Majek | last post by:
I have an ASPX application where I display a series of questions in a mult-line textbox with several blank lines between the questions so the user can supply answers. I would like to display the...
4
by: Fang | last post by:
I try to use "\n" as line feed to put text into different lines in textBox of Visual Studio .Net, but it does not work. The text is still in one line. Does anybody know how to put text into...
2
by: Abubakar | last post by:
Hi ya'all, I want to know how can I write multiple font text in a textbox , like it can be done in a rich textbox? I DONT want to use richtextbox control. I want to write multiple size text with...
6
by: Tom McLaughlin | last post by:
How can I determine the numbers of lines of text that are visible in a textbox? Tom
3
by: HDB | last post by:
Ok. I have a windows form with a textbox for displaying certain messages. Multiline=true and wordwrap=true. I want to know the amount of the lines currently showing. That should not be any...
2
by: Becker | last post by:
This is probably a very dumb question, I am using VB.NET 2003 and I see where I can use a method to append text to a textbox, but how about remove? I have a textbox that I continually post log type...
1
by: Shawn | last post by:
Anybody know how to use wordwrap=true and multiline = true on a textbox, but still have the textbox.lines attribute advance if the wordwrap happens? I have a large textbox that is setup like this...
6
by: =?Utf-8?B?SGFucyAtIERpYUdyYXBoSVQgLQ==?= | last post by:
Hi! sorry for a dumb question. I have a textbox where multiline=true and I want to set the scrolbar from none to vertical when the textbox have more then f.ex. 5 lines, or reverse. How can...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.