This is my first C# app, but I have some knowledge of a bunch of languages like VB6 and PHP, so I'm picking it up rather quickly. I've been pulling my hair out on this one for about 4 hours now.
I have a DirectoryInfo on my parent form: (extra bits chopped out...)
Expand|Select|Wrap|Line Numbers
- public partial class frmMain : Form
- {
- public DirectoryInfo diTemp;
- private void frmMain_Load(object sender, EventArgs e)
- {
- diTemp = Directory.CreateDirectory("c:\\temp");
- }
- private void btn1B_ExportCSV_Click(object sender, EventArgs e)
- {
- frm1B_ExportCSV f = new frm1B_ExportCSV();
- f.ShowDialog(this);
- }
- public string setWorkingDir(string strSubdir)
- {
- diTemp.CreateSubdirectory(strSubdir);
- return diTemp.FullName + "\\" + strSubdir;
- }
- }
Expand|Select|Wrap|Line Numbers
- public partial class frm1B_ExportCSV : Form
- {
- private string strWorkingDir;
- private void frm1B_ExportCSV_Load(object sender, EventArgs e)
- {
- strWorkingDir = ((frmMain)this.ParentForm).setWorkingDir("1B");
- }
- }
I wish I would have kept better records of what all I've tried, but I got frustrated. I can tell you I've tried accessing the DirectoryInfo directly, and several variations of things like this
Expand|Select|Wrap|Line Numbers
- //Cast MDIParent to your MDIParent Form
- theMDIParentForm theParent = (theMDIParentForm) this.MDIParent;
- //Now you can access objects on the MDI Parent form from MDI Children
- theParent.myTreeViewControl.Nodes[0].Add(new TreeNode("New Child Node"));