Any ideas?
Passing Variables to MDIChild form?
I have a project where I would like to be able to open a file on the parent MDI form which then creates a child window, I would like this child window to be able to access the filename string.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Aaron ColenPosted Oct 12, 2010, 1:11 PM
My favorite way to share strings between forms is using a static variable on the form you're sharing from.
ie:
public static string SharedString = "This is a shared string.";You can then access the string from within the parent:
private void RandomMethod(string x){
SharedString = x;
}
Or from another form by using the parent forms name (this example assumes the parent form is called Form1):
private void Method2(){
localStringVariableX = Form1.SharedString;
}