Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing Properties Between Winforms When Using Singleton
    primarykey
    data
    text
    <p>Ok so I am trying to pass a boolean from my Login form to my Home form, normally this would be fine for me and I would just use a property. However I thought I could use a similar method this time but I am implementing the singleton factory on the forms.</p> <p>Here is the Login code relevant to this: The AdminAccess property gets set fine and I have checked the value is correct.</p> <pre><code>private bool adminAccess; public bool AdminAccess { get { return adminAccess; } private set { adminAccess = value; } } private void btnLogin_Click(object sender, EventArgs e) { //Some Code Does Stuff OpenHome(); } private void OpenHome() { HomeForm CreateHomeForm = HomeForm.HomeUI; CreateHomeForm.StartupHome = this; //Trying to set the property. CreateHomeForm.AdminPermissions= this.AdminAccess; CreateHomeForm.Show(); this.Hide(); } </code></pre> <p>Here is the relevant code from the Home form:</p> <pre><code>public HomeForm() { InitializeComponent(); //just to check what is in the property quickly textBox1.Text = AdminPermissions.ToString(); } private bool adminPermissions; public bool AdminPermissions { private get { return adminPermissions; } set { adminPermissions = value; } } public Form StartupHome { set; get; } private static HomeForm homeUI; public static HomeForm HomeUI { get { if (homeUI == null || homeUI.IsDisposed) { homeUI = new HomeForm(); } return homeUI; } } </code></pre> <p>The value gets reset when the HomeUI if loop runs as a new instance of the form is created. I can't seem to think how to modify this to get a working solution. As you can tell I am fairly amateur so I'm just looking for a quick and clean solution to this :) Thank you very much for your time in advance!<b></b></p>
    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.
    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