- Joined
- May 18, 2006
- Messages
- 2,064
- Reaction score
- 14
I have a problem. This worked for me all the time, but not this time I really don't know why. I tried experimenting with it and no luck.
That's my log code for a richtextbox. It works, but I can't make it work when it's called outside of a class. I even tried using static, and putting in Form1 frm = new Form1(); and replaced logbox with frm.logbox
It doesn't even append any text to the rtb. I even tried changing the rtb's modifier to public.
No error messages are produced and do anyone know why?
Code:
public void AddLine(Font font, Color color, string text, bool Timestamp)
{
logbox.SelectionColor = color;
logbox.SelectionFont = font;
string timestamp = "";
if (Timestamp)
timestamp = "[" + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString() + ":" + DateTime.Now.Millisecond.ToString() + "] ";
logbox.AppendText(timestamp + text);
logbox.SelectionColor = Color.Black;
logbox.SelectionFont = enhance;
}
That's my log code for a richtextbox. It works, but I can't make it work when it's called outside of a class. I even tried using static, and putting in Form1 frm = new Form1(); and replaced logbox with frm.logbox
It doesn't even append any text to the rtb. I even tried changing the rtb's modifier to public.
No error messages are produced and do anyone know why?

