G
Greg Merideth
An app I'm working on has a "message" box docked to the bottom of the window to
display messages. I've added a series of child windows to the main form and
wanted to keep passing messages into the docked window. The main app has a
method to take the string, format it and then add it to the rich text box.
I created a delegate to be able to call the main methods RichTextAddLine but in
order to get it to work I had to set the richtextBox static. The compiler
would tell me that it was expecting a class and a field was given in the
RichTextAddLine method after I made the method public static call.
Is there a better way to create the delegate in the second class to be able to
call the RichTextAddLine method without making it and every window form item it
uses static?
Here's what I'm using now
// in the class definition
private delegate void RichTextWriteOP(string _lpMessage);
RichTextWriteOP RichTextWriter = new RichTextWriteOP(_frmMain.RichTextAddLine);
and in the _frmMain class
public static void RichTextAddLine(string _slpMessage)
{
...write to the screen's rich text box element
}
It works now as long as I make the method and the form elements that interact
with this method static.
Thanks for any advice.
display messages. I've added a series of child windows to the main form and
wanted to keep passing messages into the docked window. The main app has a
method to take the string, format it and then add it to the rich text box.
I created a delegate to be able to call the main methods RichTextAddLine but in
order to get it to work I had to set the richtextBox static. The compiler
would tell me that it was expecting a class and a field was given in the
RichTextAddLine method after I made the method public static call.
Is there a better way to create the delegate in the second class to be able to
call the RichTextAddLine method without making it and every window form item it
uses static?
Here's what I'm using now
// in the class definition
private delegate void RichTextWriteOP(string _lpMessage);
RichTextWriteOP RichTextWriter = new RichTextWriteOP(_frmMain.RichTextAddLine);
and in the _frmMain class
public static void RichTextAddLine(string _slpMessage)
{
...write to the screen's rich text box element
}
It works now as long as I make the method and the form elements that interact
with this method static.
Thanks for any advice.