Getting data from mdichild to mdiparent

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

    Getting data from mdichild to mdiparent

    Hello all

    I have 2 questions
    First: I'm trying to print a Listview from an mdichild but how can i
    address this listview.

    For example,

    FrmMain is my Main form.
    In this Main form I have several mdichildren.
    When i press the print button, I want to print the Listview on the
    active mdichild,

    But how can i address that.

    I'm thinking of something like this.

    dim oF as new Form
    of = me.activemdichi ld

    printing(of.lis tview1)

    Is this correct or how can i address it

    Second question:

    When I do a mouseover event on a Textbox in my MdiChild I want to
    address a Label on my MdiParent that gives information about that
    specific Textbox

    How can i do this, I think with Delegates but I'm not sure, If someone
    could give me an example, I would be very grateful,

    Thanks in advance, and sorry about my bad English but I'm from Belgium

  • Armin Zingler

    #2
    Re: Getting data from mdichild to mdiparent

    "Thorgal" <declerck_peter @yahoo.comschri eb
    Hello all
    >
    I have 2 questions
    First: I'm trying to print a Listview from an mdichild but how can i
    address this listview.
    >
    For example,
    >
    FrmMain is my Main form.
    In this Main form I have several mdichildren.
    When i press the print button, I want to print the Listview on the
    active mdichild,
    >
    But how can i address that.
    >
    I'm thinking of something like this.
    >
    dim oF as new Form
    "New" doesn't make sense here. The reference is overwritten in the next line
    anyway.
    of = me.activemdichi ld
    >
    printing(of.lis tview1)
    >
    Is this correct or how can i address it
    The type of variable 'of' is 'Form'. Not every Form has a property called
    'listview1', thus it doesn't work. You must check whether the type of the
    active Form is the one with a listview called 'listview1'. If it is, cast to
    that type, in order to access the listview:

    if typeof of is MyChildWithATre eview then
    dim f as MyChildWithATre eview = directcast(of, MyChildWithATre eview)
    printing(f.List view1)
    end if

    Second question:
    >
    When I do a mouseover event on a Textbox in my MdiChild I want to
    address a Label on my MdiParent that gives information about that
    specific Textbox
    >
    How can i do this, I think with Delegates but I'm not sure, If
    someone could give me an example, I would be very grateful,
    There are many ways to do this. It also depends on where the additional
    information for the textbox is stored and how the textboxes are created
    (designer?).

    I would probably store the additional information as an additional property
    of the textbox, which means deriving a class from Textbox and adding the
    property. At run time, after the Form and it's textboxes have been created,
    raise an event. Catch the event in the MDI parent. In the event handler, use
    a loop to retrieve all Textboxes of that type. For each Textbox found, add a
    handler to the MouseOver event. The handler is part of the MDI parent. There
    you can display the additional information.

    Another way is to "bubble" the event: Handle the MouseOver event in the Mdi
    child. You can use one single event handler for this. In the child, raise an
    event that is caught by the Mdi parent. In the parent, display the
    additional information. ... Thinking about it, the 2nd solution is probably
    the simpler one.
    Thanks in advance, and sorry about my bad English but I'm from
    Belgium
    Sorry about mine, I'm from Germany. :-) (and I think yours isn't bad at
    all!)


    Armin

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Getting data from mdichild to mdiparent

      Thjorgal,

      In my expirience is the use of the MDI collection in the MDIparent the most
      easy way to transfer data from one to another.

      Cor


      "Thorgal" <declerck_peter @yahoo.comschre ef in bericht
      news:1170833898 .687447.270330@ a34g2000cwb.goo glegroups.com.. .
      Hello all
      >
      I have 2 questions
      First: I'm trying to print a Listview from an mdichild but how can i
      address this listview.
      >
      For example,
      >
      FrmMain is my Main form.
      In this Main form I have several mdichildren.
      When i press the print button, I want to print the Listview on the
      active mdichild,
      >
      But how can i address that.
      >
      I'm thinking of something like this.
      >
      dim oF as new Form
      of = me.activemdichi ld
      >
      printing(of.lis tview1)
      >
      Is this correct or how can i address it
      >
      Second question:
      >
      When I do a mouseover event on a Textbox in my MdiChild I want to
      address a Label on my MdiParent that gives information about that
      specific Textbox
      >
      How can i do this, I think with Delegates but I'm not sure, If someone
      could give me an example, I would be very grateful,
      >
      Thanks in advance, and sorry about my bad English but I'm from Belgium
      >

      Comment

      Working...