Communicating between classes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Playne

    #1

    Communicating between classes

    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.


  • Aravind C

    #2
    Re: Communicating between classes

    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


    "Matthew Playne" <anonymous@disc ussions.microso ft.com> wrote in message
    news:031501c3b1 67$be4f4600$a30 1280a@phx.gbl.. .[color=blue]
    > 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.
    >
    >[/color]


    Comment

    • Matthew Playne

      #3
      Re: Communicating between classes

      Thanks Aravind,

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

      Matthew
      [color=blue]
      >-----Original Message-----
      >Hi Matthew,
      >
      >Usually, modifying the designer generated code by hand,[/color]
      can cause[color=blue]
      >the winforms designer to get confused, and that's[/color]
      probably why the menu item[color=blue]
      >disappears in the designer view when you changed the[/color]
      menuitem to[color=blue]
      >a static member.
      >
      >You can possibly try to pass a reference to your parent[/color]
      window[color=blue]
      >when you create an instance of the child window.
      >The child window can stash away the reference to the[/color]
      parent[color=blue]
      >window, and then call an appropriate method in the[/color]
      parent window[color=blue]
      >that causes the menuitem to be updated when the text in[/color]
      the RichTextBox[color=blue]
      >is selected. Alternatively, you can pass a reference to[/color]
      the menuitem alone[color=blue]
      >to the child window.
      >
      >Regards,
      >Aravind C
      >
      >
      >"Matthew Playne" <anonymous@disc ussions.microso ft.com>[/color]
      wrote in message[color=blue]
      >news:031501c3b 167$be4f4600$a3 01280a@phx.gbl. ..[color=green]
      >> 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[/color][/color]
      in[color=blue][color=green]
      >> the richTextBox is bullet indented, a menu option on[/color][/color]
      the[color=blue][color=green]
      >> parent window is toggled on or off depending on what is
      >> selected in the richTextBox.
      >>
      >> The problem I am having is changing the checked[/color][/color]
      property[color=blue][color=green]
      >> of the menuItem. when I make the menuItem "public[/color][/color]
      static"[color=blue][color=green]
      >> all seems to work except that after running the
      >> application, the menuItem dissapears in Visual C#[/color][/color]
      design[color=blue][color=green]
      >> 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.
      >>
      >>[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...