471,348 Members | 1,250 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Passing Data in MDI Parent form and Child Form

Hi and Hello.
Im new at .net framework. Now Im using C# . I have a little problem.
How can I get a value of a text in the mdi parent form to child form.

Example in VB6:

form1.text1.text = MainForm.text1.text

How to convert it to C#
--
To be Happy is To be Yourself
Apr 10 '08 #1
2 9391
The best approach is to create a public (or internal) property that
exposes this, and access the text through the property - i.e.

## in Form1.cs ##

public string CaptionText {
get {return text1.Text;}
set {text1.Text = value;}
}

## in parent ## (where form1 is an instance of Form1)

form1.CaptionText = "abc";

## end ##

That way, the UI details are properly encapsulated inside Form1.

Marc
Apr 10 '08 #2
As far as I know, an MDI container (MainForm) cannot have a control within
it, only MDI children. In general though, you could have code in your Shown
or Load event handlers with in the form1 form that look like this:

Text1.Text = ((MainForm) ParentForm).Text1.Text;
"Saimvp" wrote:
Hi and Hello.
Im new at .net framework. Now Im using C# . I have a little problem.
How can I get a value of a text in the mdi parent form to child form.

Example in VB6:

form1.text1.text = MainForm.text1.text

How to convert it to C#
--
To be Happy is To be Yourself
Apr 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Henry | last post: by
1 post views Thread by Tim Wallace | last post: by
reply views Thread by Sakharam Phapale | last post: by
5 posts views Thread by kevininstructor | last post: by
1 post views Thread by Ronak mishra | last post: by

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.