Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:29:51+00:00 2026-06-02T10:29:51+00:00

Ok so I am trying to pass a boolean from my Login form to

  • 0

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.

Here is the Login code relevant to this:
The AdminAccess property gets set fine and I have checked the value is correct.

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();
    }

Here is the relevant code from the Home form:

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;
        }
    }

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:29:52+00:00Added an answer on June 2, 2026 at 10:29 am

    You assign the value in the constructor, BEFORE the AdminPermissions property is actually set. Change your code like this

    public class HomeForm
    {
        public HomeForm()
        {
            InitializeComponent();
        }
    
        private bool adminPermissions;  
        public bool AdminPermissions
        {
            get { return adminPermissions; }
            set { 
                adminPermissions = value;
                textBox1.Text = value.ToString();
            }
        }
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make this function download file from the internet. I pass
I am trying to pass a little-b boolean as an argument in this call:
I'm trying to pass a java.util.Stack object from an Activity to another in an
I am trying to pass values of textbox with same name from JSP to
I'm trying to pass an array through jquery ajax call. However, I need to
I'm trying to pass a boolean into my vertex shader for the first time;
I'm having problems trying to pass an Integer object from a driver class as
I am trying to create a user login/creation script in PHP and would like
I am trying pass class as value in hashmap. I need to get the
Trying to pass something to something else. Says undefined. Not sure how or why.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.