Communicating between classes

  • Thread starter Thread starter Matthew Playne
  • Start date Start date
M

Matthew Playne

Hi,

I am having a problem communicating between to classes.
I have an MDI application. The parent window contains a
mainMenu and a toolbar and toolbuttons, and the child
form contains a richTextBox.

What I am trying to do is to when a the selected text in
the richTextBox is bullet indented, a menu option on the
parent window is toggled on or off depending on what is
selected in the richTextBox.

The problem I am having is changing the checked property
of the menuItem. when I make the menuItem "public static"
all seems to work except that after running the
application, the menuItem dissapears in Visual C# design
view. Then dissapears when I next run the application.
The code is still there, but the control doesn't appear
on the form. Obviously I am doing something wrong, if
only I could figure out what it is!

I would appreciate any assistance.
 
Hi Matthew,

Usually, modifying the designer generated code by hand, can cause
the winforms designer to get confused, and that's probably why the menu item
disappears in the designer view when you changed the menuitem to
a static member.

You can possibly try to pass a reference to your parent window
when you create an instance of the child window.
The child window can stash away the reference to the parent
window, and then call an appropriate method in the parent window
that causes the menuitem to be updated when the text in the RichTextBox
is selected. Alternatively, you can pass a reference to the menuitem alone
to the child window.

Regards,
Aravind C
 
Thanks Aravind,

That explaination sorted it out for me.
Now it actually works!

Matthew
 
Back
Top