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

communicate multiple form

P: n/a
Hi all,

I' facing a problem here that i am stucked with since i started with.net

in vb6.0 i used for example Form1.txtName.text = "test"
in vb.net i used DirectCast(Me.MdiParent,
Form1).txtName.text = "test"
and in C# i use ?

i have a settingsform where users can make changes of in and output's
these changes must be changed on the mdiparrent form.

So how can i call a function on an MDIparrent from a childform
Thanks Maarten
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Maarten,

In C#, you would do:

// Call something on the MDI parent.
((Form1) this.MdiParent).txtName.Text = "test";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
Hi all,

I' facing a problem here that i am stucked with since i started with.net

in vb6.0 i used for example Form1.txtName.text = "test"
in vb.net i used DirectCast(Me.MdiParent,
Form1).txtName.text = "test"
and in C# i use ?

i have a settingsform where users can make changes of in and output's
these changes must be changed on the mdiparrent form.

So how can i call a function on an MDIparrent from a childform
Thanks Maarten

Nov 16 '05 #2

P: n/a
hi
in c# casting is done reversed like variable declaration

so instead of DirectCast(myVariable, myType)

you just put the type first in Parens Like this

(myType)myVariable
Hope that helps

Tal McMahon

Nov 16 '05 #3

P: n/a
Hi,

thanks, but when use this code:
((Form1) this.MdiParent).txtname.Text = "test";

i get this error?

D:\visual projects (net)\C#\WindowsApplication3\FrmConf.cs(87):
'WindowsApplication3.Form1.txtname' is inaccessible due to its protection
level

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:eH*************@TK2MSFTNGP15.phx.gbl...
Maarten,

In C#, you would do:

// Call something on the MDI parent.
((Form1) this.MdiParent).txtName.Text = "test";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
Hi all,

I' facing a problem here that i am stucked with since i started with.net

in vb6.0 i used for example Form1.txtName.text = "test"
in vb.net i used DirectCast(Me.MdiParent,
Form1).txtName.text = "test"
and in C# i use ?

i have a settingsform where users can make changes of in and output's
these changes must be changed on the mdiparrent form.

So how can i call a function on an MDIparrent from a childform
Thanks Maarten


Nov 16 '05 #4

P: n/a
Maarten,

Yes, the txtName field is not public. In order to access it, you need
to change the declaration from private or protected to public (or internal,
if the classes are in the same assembly), so that classes outside of the MDI
parent class can access it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
Hi,

thanks, but when use this code:
((Form1) this.MdiParent).txtname.Text = "test";

i get this error?

D:\visual projects (net)\C#\WindowsApplication3\FrmConf.cs(87):
'WindowsApplication3.Form1.txtname' is inaccessible due to its protection
level

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:eH*************@TK2MSFTNGP15.phx.gbl...
Maarten,

In C#, you would do:

// Call something on the MDI parent.
((Form1) this.MdiParent).txtName.Text = "test";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
Hi all,

I' facing a problem here that i am stucked with since i started with.net

in vb6.0 i used for example Form1.txtName.text = "test"
in vb.net i used DirectCast(Me.MdiParent,
Form1).txtName.text = "test"
and in C# i use ?

i have a settingsform where users can make changes of in and output's
these changes must be changed on the mdiparrent form.

So how can i call a function on an MDIparrent from a childform
Thanks Maarten



Nov 16 '05 #5

P: n/a
Thank you,

it works fine

I was wondering how the comunication of Multiple Documet Inteface between
forms is done
in larger scale programs

For example photoshop, i beleave this is written in C++
Is this done by a simular way, or is that something beond my immagination.

greets Maarten

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:eU**************@TK2MSFTNGP12.phx.gbl...
Maarten,

Yes, the txtName field is not public. In order to access it, you need
to change the declaration from private or protected to public (or
internal, if the classes are in the same assembly), so that classes
outside of the MDI parent class can access it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
Hi,

thanks, but when use this code:
((Form1) this.MdiParent).txtname.Text = "test";

i get this error?

D:\visual projects (net)\C#\WindowsApplication3\FrmConf.cs(87):
'WindowsApplication3.Form1.txtname' is inaccessible due to its protection
level

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
schreef in bericht news:eH*************@TK2MSFTNGP15.phx.gbl...
Maarten,

In C#, you would do:

// Call something on the MDI parent.
((Form1) this.MdiParent).txtName.Text = "test";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
Hi all,

I' facing a problem here that i am stucked with since i started
with.net

in vb6.0 i used for example Form1.txtName.text = "test"
in vb.net i used DirectCast(Me.MdiParent,
Form1).txtName.text = "test"
and in C# i use ?

i have a settingsform where users can make changes of in and output's
these changes must be changed on the mdiparrent form.

So how can i call a function on an MDIparrent from a childform
Thanks Maarten



Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.