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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:06:10+00:00 2026-06-09T21:06:10+00:00

I am trying to write a simple C# password saver utility in MS Visual

  • 0

I am trying to write a simple C# password saver utility in MS Visual Studios. I have a listView in formA and I want to use formB to add a new item to the list.

FormB calls forceAdd which is a member of formA. forceAdd then updates the data set and attempts to refresh the listView by calling populateList().

The problem is that the listView does not reflect the changes until I call my populateList() function by a button or check box in formA.

For example, I can call populateList() 50 times in my code to no avail, but as soon as I call it from a button on formA it works.

(DieselPass = fromA, newForm = FormB, newForm::Save calls forceAdd, formA::new opens newForm)

(when i wire the formA::Edit… button up to populate and click it after save, the listView updates)

I’m a new user… this image explains it:
http://i50.tinypic.com/wk6bys.jpg

    public void forceAdd(String a, String u, String p)
    {
        accountsDataSet.tblAccounts.AddtblAccountsRow(a, u, p);
        tblAccountsTableAdapter.Update(accountsDataSet.tblAccounts);
        populateList();
    }

    private void populateList()
    {
        //make sure data set is up to date
        this.tblAccountsTableAdapter.Fill(this.accountsDataSet.tblAccounts);
        //clear existing items
        listView1.Items.Clear();
        for (int i = 0; i < accountsDataSet.tblAccounts.Count; i++)
        {
            String[] wtf;
            if (maskPasswords)
                wtf = new string[] { accountsDataSet.tblAccounts[i].Account, accountsDataSet.tblAccounts[i].Username };
            else
                wtf = new string[] { accountsDataSet.tblAccounts[i].Account, accountsDataSet.tblAccounts[i].Username, accountsDataSet.tblAccounts[i].Password };
            lvi = new ListViewItem(wtf);
            Console.WriteLine(lvi.ToString());
            listView1.Items.Add(lvi);
        }
    }

Things I’ve already tried include:

    listView1.Update();
    listView1.BeginUpdate();
    ...
    listView1.EndUpdate();
    listView1.Refresh();
    listView1.Clear();
    listView1.RedrawItems(0,i,t/f);
    this.Update();
    this.Refresh();

Any help or tips would be greatly appreciated, Thanks.

More Code:

FormA setting up reference in formB:

    myNewForm.getForm = this;

FormB’s reference to formA:

    private mainForm myForm = new mainForm();
    public mainForm getForm
    {
        get { return myForm; }
        set { myForm = value; }
    }        

FormB calling FormA’s function:

    myForm.forceAdd(accountBox.Text.ToString(), usernameBox.Text.ToString(), passwordBox.Text.ToString());

Is this an instance where I need to do an “invoke/delegate” ?

Edit 2:

Sorry I wasn’t clear enough, FormB calls FormA::populateList(), I put Console output in the function to confirm this, it successfully adds items to the data set but just wont refresh the list. Its like it knows that this is an outside form that just wont let it refresh.

I also made populateList public, didnt work

Visual studios wont let me call pupulateList() from (mainForm)this.Parent. even after caling myNewForm.ShowDialog(this); do I have to include something or pass it some other way?

my reference to formA through myForm works, just not with updating lists..?

Edit 3:
This doesnt work either:

((mainForm)this.Parent).populateList();
  • 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-09T21:06:11+00:00Added an answer on June 9, 2026 at 9:06 pm

    FormB will have to have a reference to the instance of FormA. You can pass this reference to FormB when the insert button is clicked:

    in FormA

    FormB PWDForm= new FormB();
    FormB.ShowDialog(this);
    

    Next on FormB you can access FormA like this:

    (FormA)this.Parent.populateList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write simple proxy server for some purpose. In it I use
I am trying to write header file. I can write simple headers like add(int
I'm trying write a simple perl script that reads some fields from a password
I am trying to run a simple password validator. I have already written it
I am trying to write a simple Gui to produce a random password. The
I am trying to write a simple INSERT statement to add new users to
I'm trying to write a simple password program in Python that allows 3 attempts
I trying to write a simple function to call unmanaged code from managed code.
I am trying to write some simple code which will read a text file
I am trying to write a simple application to interact with NFC tags, but

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.