• Welcome to Valhalla Legends Archive.
 

[C#]AppendRTB

Started by Mangix, September 17, 2005, 12:07 PM

Previous topic - Next topic

Mangix

im making a void to Append Text to a Rich Text Box but im having one problem. i cant set the color.

void AppendRTB(System.Windows.Forms.RichTextBox rtb, string text, System.Drawing.Color color)
{
rtb.SelectionStart = rtb.Text.Length;
rtb.SelectionLength = 0;
rtb.SelectedText = text;
rtb.SelectionColor = color;
rtb.SelectionStart = rtb.Text.Length;
}


i've tried using just the color name but it says it doesnt exist. i also tried using Color.colorname which doesnt error but it doesnt change the color. it's still black.

also, how do i make a newline in .NET?

MyndFyre

Quote from: Mangix on September 17, 2005, 12:07 PM
im making a void to Append Text to a Rich Text Box but im having one problem. i cant set the color.

void AppendRTB(System.Windows.Forms.RichTextBox rtb, string text, System.Drawing.Color color)
{
rtb.SelectionStart = rtb.Text.Length;
rtb.SelectionLength = 0;
rtb.SelectedText = text;
rtb.SelectionColor = color;
rtb.SelectionStart = rtb.Text.Length;
}


i've tried using just the color name but it says it doesnt exist. i also tried using Color.colorname which doesnt error but it doesnt change the color. it's still black.

also, how do i make a newline in .NET?
Try selecting the text (by specifying the SelectionLength as text.Length after adding the text?  Otherwise IDK.

Environment.NewLine.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Mangix

#2
i fixed it somehow. dunno why but the same code now works. weird.

edit:do you know how i can do a perfect Now function? right now im using this code to produce a Time. string tmeNow = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString(); now i dont like this code. sometimes it produces a time value like this.

Quote12:3:7
the real time is 12:30:07 but that's what i want it to show. the zeroes behind it.

Insolence

That's very easy, if < 10 +=  " ", then tack on the minute(s)/second(s) :)

MyndFyre

#4
I'm going to throw out a REALLY crazy suggestion...

If you have MSDN documentation, you can see the codes for the DateTime format strings here: ms-help://ms.vscc.2003/MS.MSDNQTR.2004OCT.1033/cpguide/html/cpconcustomdatetimeformatstrings.html (copy-paste that into MSDN document reader)

(This links to October 2004 MSDN, which is the most recent that I had).


How about:

DateTime.Now.ToString("HH:mm:ss")


I've noticed people like to do things the hard way when easy ways to do stuff exist automatically.  :P
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Mangix

dont you mean the MSDN Library? i have the Beta 2 but i cant access it. reason is because it's supposed to be used with VS 2005 products but i uninstalled all of em(cept for SQL Server(i cant get rid of it -_-)). right now the whole library is in weird .hks files(i think). it's also zipped in an archive.

edit:as for the Now, thanks a lot :) oh and just so you know, i dont think i cant use any version of the MSDN Libarary cause i use SharpDevelop :-\