hi,
i'm trying to use the RichTextBoxSelectionColor property, but in any
combination of command order i try, the text color is not changed. the
only time it worked was when i set SelectionStart = 0.
here's one version i tried:
String res = "Failed";
int selectionStart = rtbTestResult.TextLength;
rtbTestResult.AppendText(res + Environment.NewLine);
// OR rtbTestResult.Text += res + Environment.NewLine;
rtbTestResult.SelectionStart = selectionStart;
rtbTestResult.SelectionLength = res.Length;
rtbTestResult.SelectionColor = Color.Red;
any ideas? 4 3094
Hi,
I am unable to verify your problem. Your code works as expected. The
word Failed is appended to whatever text is present, and the word is
indeed colored red.
If you open a new project, using only the RichTextBox, do you still get no
color?
On Mon, 04 Sep 2006 11:54:00 +0200, <ts********@gmail.comwrote:
hi,
i'm trying to use the RichTextBoxSelectionColor property, but in any
combination of command order i try, the text color is not changed. the
only time it worked was when i set SelectionStart = 0.
here's one version i tried:
String res = "Failed";
int selectionStart = rtbTestResult.TextLength;
rtbTestResult.AppendText(res + Environment.NewLine);
// OR rtbTestResult.Text += res + Environment.NewLine;
rtbTestResult.SelectionStart = selectionStart;
rtbTestResult.SelectionLength = res.Length;
rtbTestResult.SelectionColor = Color.Red;
any ideas?
--
Happy Coding!
Morten Wennevik [C# MVP]
Morten Wennevik wrote:
Hi,
I am unable to verify your problem. Your code works as expected. The
word Failed is appended to whatever text is present, and the word is
indeed colored red.
i get it in black. can it be related to the fact that subsequent calls
to this method add more text to the richtextbox, in another case block?
(the code above is in a case block of a switch statement).
If you open a new project, using only the RichTextBox, do you still get no
color?
i tried to make a simple app, where i preloaded the textbox with lorem
ipsum, and on a button click event i did SelectionColor = Color.Red,
and indeed any text i selected with the mouse was painted red. in this
case, however, rtbTestResults.ReadOnly = true.
while writing this post i tried to set HideSelection = false, and
"Failed" blinked in red for a moment, but when more text was added, it
turned black again.
tsahi
On Mon, 04 Sep 2006 11:54:00 +0200, <ts********@gmail.comwrote:
hi,
i'm trying to use the RichTextBoxSelectionColor property, but in any
combination of command order i try, the text color is not changed. the
only time it worked was when i set SelectionStart = 0.
here's one version i tried:
String res = "Failed";
int selectionStart = rtbTestResult.TextLength;
rtbTestResult.AppendText(res + Environment.NewLine);
// OR rtbTestResult.Text += res + Environment.NewLine;
rtbTestResult.SelectionStart = selectionStart;
rtbTestResult.SelectionLength = res.Length;
rtbTestResult.SelectionColor = Color.Red;
any ideas?
--
Happy Coding!
Morten Wennevik [C# MVP]
ts********@gmail.com wrote:
Morten Wennevik wrote:
Hi,
I am unable to verify your problem. Your code works as expected. The
word Failed is appended to whatever text is present, and the word is
indeed colored red.
i get it in black. can it be related to the fact that subsequent calls
to this method add more text to the richtextbox, in another case block?
(the code above is in a case block of a switch statement).
If you open a new project, using only the RichTextBox, do you still get no
color?
i tried to make a simple app, where i preloaded the textbox with lorem
ipsum, and on a button click event i did SelectionColor = Color.Red,
and indeed any text i selected with the mouse was painted red. in this
case, however, rtbTestResults.ReadOnly = true.
while writing this post i tried to set HideSelection = false, and
"Failed" blinked in red for a moment, but when more text was added, it
turned black again.
tsahi
On Mon, 04 Sep 2006 11:54:00 +0200, <ts********@gmail.comwrote:
hi,
i'm trying to use the RichTextBoxSelectionColor property, but in any
combination of command order i try, the text color is not changed. the
only time it worked was when i set SelectionStart = 0.
>
here's one version i tried:
>
String res = "Failed";
int selectionStart = rtbTestResult.TextLength;
rtbTestResult.AppendText(res + Environment.NewLine);
// OR rtbTestResult.Text += res + Environment.NewLine;
rtbTestResult.SelectionStart = selectionStart;
rtbTestResult.SelectionLength = res.Length;
rtbTestResult.SelectionColor = Color.Red;
>
any ideas?
>
--
Happy Coding!
Morten Wennevik [C# MVP]
i fixed it. i replaced all calls to Text += "some string" to
AppendText("some string"), and it works. it must be something with this
+= operator.
I don't think using AppendText instead of += is the reason you got black
text. More likely you overwrote the red text with black at a later point.
Glad to see it works now, though.
On Mon, 04 Sep 2006 20:49:58 +0200, <ts********@gmail.comwrote:
> ts********@gmail.com wrote:
>Morten Wennevik wrote:
Hi,
I am unable to verify your problem. Your code works as expected. The
word Failed is appended to whatever text is present, and the word is
indeed colored red. i get it in black. can it be related to the fact that subsequent calls to this method add more text to the richtextbox, in another case block? (the code above is in a case block of a switch statement).
If you open a new project, using only the RichTextBox, do you still
get no
color?
i tried to make a simple app, where i preloaded the textbox with lorem ipsum, and on a button click event i did SelectionColor = Color.Red, and indeed any text i selected with the mouse was painted red. in this case, however, rtbTestResults.ReadOnly = true.
while writing this post i tried to set HideSelection = false, and "Failed" blinked in red for a moment, but when more text was added, it turned black again.
tsahi
On Mon, 04 Sep 2006 11:54:00 +0200, <ts********@gmail.comwrote:
hi,
i'm trying to use the RichTextBoxSelectionColor property, but in any
combination of command order i try, the text color is not changed..
the
only time it worked was when i set SelectionStart = 0.
here's one version i tried:
String res = "Failed";
int selectionStart = rtbTestResult.TextLength;
rtbTestResult.AppendText(res + Environment.NewLine);
// OR rtbTestResult.Text += res + Environment.NewLine;
rtbTestResult.SelectionStart = selectionStart;
rtbTestResult.SelectionLength = res.Length;
rtbTestResult.SelectionColor = Color.Red;
any ideas?
--
Happy Coding!
Morten Wennevik [C# MVP]
i fixed it. i replaced all calls to Text += "some string" to
AppendText("some string"), and it works. it must be something with this
+= operator.
--
Happy Coding!
Morten Wennevik [C# MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hariharan S |
last post by:
Hi Guys,
I have a string, say "Hello World" and would like to format the way I want
to (say, wanna have the Hello to be bold italic and the World to be of font
size 14 or so) and put it in the...
|
by: kangoo |
last post by:
Hi,
I'm trying to remove the last charater in a richTextBox. I though
richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but
it does nothing
(eg richTextBox.Text += "some new...
|
by: Martin Dew |
last post by:
I have a RichTextBox called rtbOutput.
I am adding lines of text using the AppendText method. What I want to do is
immediately after adding this line of text make sure that this line of text
is...
|
by: Carlos Lozano |
last post by:
I need to merge the content of two richtextboxes.
It can not be accomplished using the RichtTextBox.Text field because all
format will be lost. So it has to be done using the RichtTextBox.Rtf...
|
by: TheBinar |
last post by:
Hi
I have a user control that contains a RichTextBox in vb.net. In my
program, I create multiple instances of this control (with the
RichTextBox being in each one), that appear one above the...
|
by: Clark Stevens |
last post by:
Hi. This should be so easy, but I don't get it. Let say I have
RichTextbox1 and I want to insert some text at the current insertion point,
or at the beginning of selected text (if there is any). ...
|
by: Al |
last post by:
Hi
Is there any what to convert content of a richTexBoxt from rtf to text?
thanks
Al
|
by: michael sorens |
last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a
very simple task but I cannot find information on this. I am using a
RichTextBox as an output window. Some text I want to...
|
by: drfreaky |
last post by:
Hello,
I want to use a richtextbox for logging status messages. I have three kind of message types and want to use different formatting for them.
My problem is, I change the color, add the text...
|
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= |
last post by:
I want to open a text file and format it into a specific line and then apply
color to a specific location of the text and then display it in a RichTextBox
after all of this is done.
I can do all...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |