Note that there are some explanatory texts on larger screens.

plurals
  1. POOpening new Windows Form from another Form
    primarykey
    data
    text
    <p>Now before anyone goes and marks this question as a duplicate, I'd like to say that my problem differs from the other ones. I'm trying to open an existing Form from another, but I'm having problems in the sense that I've set some Forms to 'host' others (To transfer variables between them). Here's what I mean:</p> <pre><code> public partial class Schedule_Tasks : Form { readonly Schedules schedules; public Schedule_Tasks(Schedules host) { this.schedules = host; InitializeComponent(); } </code></pre> <p>So in this snippet of code, I'm trying to get the value of some variables from the Schedules form, into the Schedule_Tasks Form. So I've used the 'host' system. SO far this method works fine, but my problem occurs when I try to open a specific Form, from another that isn't 'hosting'. For example using:</p> <pre><code>new Schedules().Show(); </code></pre> <p>So obviously when I'm declaring this, I'd put something like 'this' in the brackets after Schedules, but that doesn't work if the Form is being called outside of the 'host' Form. I'd just like to now is there something I'm missing or can change? Please let me know if any part isn't clear, it's a little difficult to explain. Any help is appreciated, Cheers.</p> <p><strong>EDIT</strong></p> <p>Here's the code that I'm working with now:</p> <pre><code> public partial class Schedual_Tasks : Form { readonly Scheduals scheduals; public string selectedDevice; public string getPath; public string totalPath; public Schedual_Tasks(Scheduals host) { this.scheduals = host; InitializeComponent(); selectedDevice = scheduals.itemSelected; } private void Schedual_Tasks_Load(object sender, EventArgs e) { } private void changeDirectory_Click(object sender, EventArgs e) { new Folder_Browser(this).Show(); //Error Occurs here } } </code></pre> <p>And here is the constructor for Folder_Browser, which is the Form I'm trying to call:</p> <pre><code> readonly Back_up_Options backOptions; public string deviceSel; public Folder_Browser(Back_up_Options host) { InitializeComponent(); this.backOptions = host; deviceSel = backOptions.deviceSel; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload