Author | Message | Time |
---|---|---|
Mangix | im making a void to Append Text to a Rich Text Box but im having one problem. i cant set the color. [code] 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; }[/code] 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? | September 17, 2005, 5:07 PM |
Myndfyr | [quote author=Mangix link=topic=12838.msg128500#msg128500 date=1126976860] im making a void to Append Text to a Rich Text Box but im having one problem. i cant set the color. [code] 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; }[/code] 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? [/quote] Try selecting the text (by specifying the SelectionLength as text.Length after adding the text? Otherwise IDK. Environment.NewLine. | September 17, 2005, 9:13 PM |
Mangix | 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. [code]string tmeNow = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();[/code] now i dont like this code. sometimes it produces a time value like this. [quote]12:3:7[/quote] the real time is 12:30:07 but that's what i want it to show. the zeroes behind it. | September 17, 2005, 11:11 PM |
Insolence | That's very easy, if < 10 += " ", then tack on the minute(s)/second(s) :) | September 18, 2005, 6:51 AM |
Myndfyr | 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: [code] DateTime.Now.ToString("HH:mm:ss") [/code] I've noticed people like to do things the hard way when easy ways to do stuff exist automatically. :P | September 18, 2005, 9:01 AM |
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 :-\ | September 19, 2005, 3:31 AM |