473,406 Members | 2,371 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,406 software developers and data experts.

Changing font colors of concatenated strings

Let's say you're programming in VB.NET, and you have:

Dim str1 As String
Dim str2 As String
Dim str3 As String
str1 = "I am red"
str2 = "I am yellow"
str3 = "I am dark green"

With TextBox1
.Text = str1 & ", " & str2 & ", " & str3
.SelectAll
.Copy
End With
....and you want to copy 'str' to the clipboard, with "I am red" in red
font, "I am yellow" in yellow font, and "I am dark green" in dark green
font?
I feel like I'm missing something obvious...
Thanks!

Nov 21 '05 #1
4 9526

"JoelW" <js******@rockwellcollins.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Let's say you're programming in VB.NET, and you have:

Dim str1 As String
Dim str2 As String
Dim str3 As String
str1 = "I am red"
str2 = "I am yellow"
str3 = "I am dark green"

With TextBox1
.Text = str1 & ", " & str2 & ", " & str3
.SelectAll
.Copy
End With
...and you want to copy 'str' to the clipboard, with "I am red" in red
font, "I am yellow" in yellow font, and "I am dark green" in dark green
font?
I feel like I'm missing something obvious...
Thanks!


You are copying text to the clipboard. The clipboard does not contain
anything for colors. It has no UI to display colors/strings. All it cares
about is that you are copying "data" to the clipboard to be used at a later
time. What you are copying from may display the strings in colors. For
example, if you are copying from a Rich Text Box, then when you copy the
text, you are copying the format (the Rich Text format) as well as the text.
The "data" is the format code which contains the text you are copying.

Hope this helps :)

Mythran

Nov 21 '05 #2
Then how do I get the different sections of the concatenated string to
show up as different colors in this instance?

Nov 21 '05 #3
JoelW wrote:
Then how do I get the different sections of the concatenated string to
show up as different colors in this instance?


It all depends on what you are coping to. If you sent data in html
format and the object you are pasting to accepts that format then it
will work. if you paste in Rich text format then the object you are
pasting to needs to accept that as well.

Chris
Nov 21 '05 #4
Hi,

The textbox does not support color. Use a richtextbox instead.
This code will place the text in the color you want in the richtextbox and
then copy it to the clipboard.

RichTextBox1.SelectionColor = Color.Red
RichTextBox1.SelectedText = "I am red" & ControlChars.NewLine
RichTextBox1.SelectionColor = Color.Yellow
RichTextBox1.SelectedText = "I am yellow" & ControlChars.NewLine
RichTextBox1.SelectionColor = Color.DarkGreen
RichTextBox1.SelectedText = "I am dark green" & ControlChars.NewLine
RichTextBox1.SelectAll()
RichTextBox1.Copy()
Ken
---------------------
"JoelW" <js******@rockwellcollins.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Let's say you're programming in VB.NET, and you have:

Dim str1 As String
Dim str2 As String
Dim str3 As String
str1 = "I am red"
str2 = "I am yellow"
str3 = "I am dark green"

With TextBox1
.Text = str1 & ", " & str2 & ", " & str3
.SelectAll
.Copy
End With
....and you want to copy 'str' to the clipboard, with "I am red" in red
font, "I am yellow" in yellow font, and "I am dark green" in dark green
font?
I feel like I'm missing something obvious...
Thanks!
Nov 21 '05 #5

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

Similar topics

0
by: Matt Garman | last post by:
I'd like to write a class or module in python that allows me to do on-the-fly color changing in the curses module. I'm thinking about something along the lines of this: addstr(y, x, 'hello',...
9
by: Billy | last post by:
Hi, I was wondering if it is possible to change the browsers text settings. ie. in internet explorer you can change the text size by going to: View -> Text Size Is there a way to overide a...
2
by: Mr.Baha | last post by:
Hello, I have a situation where I am appending text to a multi-line (rich)textbox in a C# form. Now depending on which event does the appendtext, i want to distinguish the lines in the textbox by...
1
by: Firewalker | last post by:
I am attempting to change the backColor property on the previously instantiated buttons FROM a listbox_doubleClick event. I thought it would be something like this: If...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
7
by: Fabien LE LEZ | last post by:
Hello, I'd like to put, on a web page, a "place" where the user can type a rather long text, with automatic coloring of each word (e.g. a color depending on the number of letters of the word). ...
1
by: iwdu15 | last post by:
hi, im trying to figure out how to get all the font and color selections of a richt text box. for instance we could have this: Red (formatted in red color and Arial font) Green (formatted in...
4
by: Sam Carleton | last post by:
How do I change the CSS colors via JavaScript DOM? Let me explain... I am working on a Windows application (in C#) that displays some HTML. In one place the HTML is a status window. What happens...
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.