communicate multiple form

  • Thread starter Thread starter Maarten
  • Start date Start date
M

Maarten

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
 
Maarten,

In C#, you would do:

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

Hope this helps.
 
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
 
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 said:
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]
- (e-mail address removed)


Maarten said:
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
 
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]
- (e-mail address removed)

Maarten said:
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 said:
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]
- (e-mail address removed)


Maarten said:
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
 
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 said:
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]
- (e-mail address removed)

Maarten said:
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 said:
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]
- (e-mail address removed)


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
 
Back
Top