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 6774863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:50:18+00:00 2026-05-26T15:50:18+00:00

I am having 3 classes. One is AuthenticateUser which let me to set and

  • 0

I am having 3 classes. One is AuthenticateUser which let me to set and get user information such as username and password. In other class, AddEntryWindow is a WinForm in which I am trying to display content of the Password and UserName properties from AuthenticateUser. third class is another WinForm class which let me to set username and password to the AuthenticateUser class. As I try, in this simplified example, to display username and password from a WinForm class I am getting a blank message box. Also, when using another message box in AuthenticateUserWindow I am able to get the content of properties.

How can I fix this to be able to view content of the property in AddEntryWindow class? I have been staring blank for past hour on this.

Probably it’s something with line: AuthenticateUser authenticateUser = new AuthenticateUser(); which create a new object. But where would it go instead?

Most likely problem in AddEntryWindow.cs

using System;
using System.Windows.Forms;
// Needed to be used with StringBuilder
using System.Text;
// Needed to be used with ArrayList.
using System.Collections;

namespace Store_Passwords_and_Serial_Codes
{
    public partial class AddEntryWindow : Form
    {
        // Making authentication possible.
        AuthenticateUser authenticateUser = new AuthenticateUser();

        // Default constructor to initialize the form.
        public AddEntryWindow()
        {
            InitializeComponent();
        }

        private void btnAddEntry_Click(object sender, EventArgs e)
        {
            MessageBox.Show(authenticateUser.UserName + authenticateUser.Password);
        }
    }
}

AuthenticateUser.cs

using System;

namespace Store_Passwords_and_Serial_Codes
{
    class AuthenticateUser
    {
        private string userName, password;

        public AuthenticateUser()
        {
        }

        public AuthenticateUser(string userNamePassed, string passwordPassed)
        {
            this.userName = userNamePassed;
            this.password = passwordPassed;
        }

        public string UserName
        {
            get
            {
                return userName;
            }
            set
            {
                userName = value;
            }
        }

        public string Password
        {
            get
            {
                return password;
            }
            set
            {
                password = value;
            }
        }
    }
}

AuthenticateUserWindow.cs

using System;
using System.Windows.Forms;

namespace Store_Passwords_and_Serial_Codes
{
    public partial class AuthenticationWindow : Form
    {
        // Most important log in information needs to be entered
        // for encrypting and decrypting binary file.
        AuthenticateUser authenticateUser;

        public AuthenticationWindow()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            // Closing Authentication Window form.
            Close();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            // Clearing text boxes txtUserName and txtPassword
            // after Clear Form button is clicked.
            txtUserName.Clear();
            txtPassword.Clear();
        }

        private void btnAuthenticate_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == string.Empty || txtPassword.Text == string.Empty)
            {
                MessageBox.Show("Please fill both information first.");
            }
            else
            {
                // Passing the values to object AuthenticateUser.
                authenticateUser = new AuthenticateUser(txtUserName.Text, txtPassword.Text);

                MessageBox.Show(authenticateUser.UserName + authenticateUser.Password);

                Close();
            }
        }
    }
}

Regards.

  • 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-05-26T15:50:18+00:00Added an answer on May 26, 2026 at 3:50 pm

    Like John said, you need to change the code as follows:

    public partial class AddEntryWindow : Form
    {
        // Making authentication possible.
        AuthenticateUser authenticateUser = new AuthenticateUser();
        // Default constructor to initialize the form.
        public AddEntryWindow()
        {
            InitializeComponent();
        }
    
        private void btnAddEntry_Click(object sender, EventArgs e)
        {
            new AuthenticationWindow(authenticateUser).ShowDialog();
            MessageBox.Show(authenticateUser.UserName + authenticateUser.Password);
        }
    }
    
    ...
    
    public partial class AuthenticationWindow : Form
    {
        // Most important log in information needs to be entered
        // for encrypting and decrypting binary file.
        AuthenticateUser authenticateUser;
    
        public AuthenticationWindow(AuthenticateUser user)
        {
            InitializeComponent();
            authenticateUser = user;
        }
    
        ...
    
        private void btnAuthenticate_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == string.Empty || txtPassword.Text == string.Empty)
            {
                MessageBox.Show("Please fill both information first.");
            }
            else
            {
                // Passing the values to object AuthenticateUser.
                authenticateUser.UserName = txtUserName.Text;
                authenticateUser.Password = txtPassword.Text;
    
                MessageBox.Show(authenticateUser.UserName + authenticateUser.Password);
    
                Close();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having 2 classes - one holding Entity information other holding Component information. Now
I like having separate classes, one class represents the entity, and that a separate
Having two projects: one is a class library (a .dll assembly) and the other
I've been having a problem with passing variables between classes. I have one class
I've created two classes, with one of them having an implicit cast between them:
There are many classes having this provider suffix. (Data,membership,modelmetadata,...). When should be a class
I need to add and delete class on an element having multiple classes: This
Having the following classes, in two different assemblies: class Member { public string Label
Does having several levels of base classes slow down a class? A derives B
I like the Java convention of having one public class per file, even if

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.