So what original program I wrote was display pdf file list on comboBox from c:\temp location. But then, I wanted to give user an option to change folder so I created another form called Form2. This Form2 only opens when user press button from Form1 and it closes when user hit save button in Form2. So, I wrote code in Form2. btnSDS opens filepath and displays the path on textBox. How do I make Form1 to get folder location from Form2?
Process
user starts program and form 1 opens and grabs pdf file name from default folder.
user wants to change default folder so he clicks admin button from form 1 and it opens form 2 which is admin form.
user changes default folder setting of folder 1 from folder 2 and closes folder 2.
default folder setting changes in folder 1.
when user opens folder 2 again, default folder setting remains in textBox in folder 2.
// Form2 private void btnSDS_Click(object sender, EventArgs e) { var folderBrowserDialog1 = new FolderBrowserDialog(); // Show the FolderBrowserDialog. DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { string folderName = folderBrowserDialog1.SelectedPath; textBoxSDSLocation.Text = folderName; } } // Form1 private void Form1_Load(object sender, EventArgs e) { DirectoryInfo test = new DirectoryInfo(@"c:\temp"); //Assuming Test is your Folder FileInfo[] Files = test.GetFiles("*.pdf"); //Getting Text files comboSDS.DataSource = Files; comboSDS.DisplayMember = "Name"; } private void comboSDS_SelectedIndexChanged(object sender, EventArgs e) { //axAcroPDF2.LoadFile(@"C:\temp\" + comboSDS.Text); //axAcroPDF2.src = @"C:\temp\" + comboSDS.Text; axAcroPDF2.LoadFile(@"Form2.textBoxSDSLocation.Text" + comboSDS.Text); axAcroPDF2.src = @"Form2.textBoxSDSLocation.Text" + comboSDS.Text; axSetting(); }