Getting data from mdichild to mdiparent

T

Thorgal

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.activemdichild

printing(of.listview1)

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
 
A

Armin Zingler

Thorgal said:
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.activemdichild

printing(of.listview1)

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 MyChildWithATreeview then
dim f as MyChildWithATreeview = directcast(of, MyChildWithATreeview)
printing(f.Listview1)
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
 
C

Cor Ligthert [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top