473,503 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MDI Child Controls question

I have an MDI form with a number of MDIChildren. Each child is identical and
has a single PictureBox on it.

One of the child forms will be the active form. I need to code something
like this:

me.activeMDIChild.Picturebox1.Image = "C:\fred.jpg"

which of course I can't do. How do I refer to this control on the active
form?

Thanks

-Jerry
Apr 4 '06 #1
2 1670
Ok there is something ActiveControl for each Form... not sure if you can use
that for a picturebox, because it can't get Focus like a textbox... so what
you can do is the below..

Dim ChildControl As Control
For Each ChildControl In Me.ActiveMdiChild.Controls
If TypeOf ChildControl Is PictureBox Then
' do your stuff here..
End If
Next

"Jerry Spence1" <je**********@somewhere.com> wrote in message
news:44***********************@ptn-nntp-reader03.plus.net...
I have an MDI form with a number of MDIChildren. Each child is identical
and has a single PictureBox on it.

One of the child forms will be the active form. I need to code something
like this:

me.activeMDIChild.Picturebox1.Image = "C:\fred.jpg"

which of course I can't do. How do I refer to this control on the active
form?

Thanks

-Jerry

Apr 4 '06 #2
Have a think about the Type (class) of the objects you are dealing with.

The type of Me.ActiveMDIChild is System.Windows.Forms.Form. The type of the
object that is actually your MDIChild is whatever name you have given it and
is derived from System.Windows.Forms.Form.

You need to cast Me.ActiveMDIChild to whatever your class is before
attempting to access the controls on it.

e.g.:

CType(Me.ActiveMDIChild, <myclass>).Picturebox1.Image = "C:\fred.jpg"
"Jerry Spence1" <je**********@somewhere.com> wrote in message
news:44***********************@ptn-nntp-reader03.plus.net...
I have an MDI form with a number of MDIChildren. Each child is identical
and has a single PictureBox on it.

One of the child forms will be the active form. I need to code something
like this:

me.activeMDIChild.Picturebox1.Image = "C:\fred.jpg"

which of course I can't do. How do I refer to this control on the active
form?

Thanks

-Jerry

Apr 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4918
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
6340
by: poi | last post by:
In VS.NET 2003, I get intellisense if I do this: LiteralControl literalControl = new LiteralControl(); literalControl.ID = "something"; literalControl.Controls.Add..... And it compiles fine...
3
7703
by: Arulraja | last post by:
Hello, I have created 2 custom server controls, The parent custom control contains multiple child custom controls. The Child control has a button on it. If I Click the button control, it...
4
1060
by: wASP | last post by:
Hi, I was under the impression that, when ASP rendered a page, it recursively traversed the hierarchy, executing all controls in each ControlCollection of every control in that hierarchy. I...
3
3195
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI...
10
3983
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
4
3598
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
4
3548
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
5
2228
by: Earl | last post by:
I need to call a method on an owned child form, and am wondering if the best way of doing this is to capture the Closing event of the form that passes control back to the form where I have the...
1
14534
by: sklett | last post by:
I've read several articles/blogs/threads about anchoring/docking child controls in a FlowLayoutPanel. It sounds like it *should* work, but I can't get it to work for the life of me. Jon Skeet: ...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.