By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,997 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,997 IT Pros & Developers. It's quick & easy.

Referencing a control on MDI Parent

P: n/a
I am just moving from VB to C# so I hope this isn't going to be too
obvious... I am trying to reference a control (status bar) on an MDI parent
from a child form and can't seem to get the syntax correct.

I have made the control public on the parent form yet get this to work.

Can anyone point me in the right directions?
Thanks
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
George,

You can't just use the name of the type of the parent form. In VB, a
static instance with the name of the type was exposed.

If I am right, you probably are using the MdiParent property on the form
to get the parent. This will have to be cast to the type of the parent
form, and then you should be able to access it, like this:

// Get the parent control.
MyParentForm pobjForm = (MyParentForm) this.MdiParent;

// Access the control.
TextBox pobjTextBox = pobjForm.TextBox1;

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"George" <ix********@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP09.phx.gbl...
I am just moving from VB to C# so I hope this isn't going to be too
obvious... I am trying to reference a control (status bar) on an MDI parent from a child form and can't seem to get the syntax correct.

I have made the control public on the parent form yet get this to work.

Can anyone point me in the right directions?
Thanks

Nov 15 '05 #2

P: n/a
Helps a bunch! Thanks
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:OG**************@TK2MSFTNGP12.phx.gbl...
George,

You can't just use the name of the type of the parent form. In VB, a
static instance with the name of the type was exposed.

If I am right, you probably are using the MdiParent property on the form to get the parent. This will have to be cast to the type of the parent
form, and then you should be able to access it, like this:

// Get the parent control.
MyParentForm pobjForm = (MyParentForm) this.MdiParent;

// Access the control.
TextBox pobjTextBox = pobjForm.TextBox1;

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"George" <ix********@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP09.phx.gbl...
I am just moving from VB to C# so I hope this isn't going to be too
obvious... I am trying to reference a control (status bar) on an MDI

parent
from a child form and can't seem to get the syntax correct.

I have made the control public on the parent form yet get this to work.

Can anyone point me in the right directions?
Thanks


Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.