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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:40:44+00:00 2026-05-15T12:40:44+00:00

I am wondering how I can update my listview in form1 by entering data

  • 0

I am wondering how I can update my listview in form1 by entering data via textboxes in form2. My code works fine if i put all the text boxes on the same form etc.

I figured I needed some reference to the first form on 2nd but can’t get it working.

Any tips for putting me in the right direction would be nice, also any tips for any better way of doing this.

This is the code I have so far:

Form1:

public partial class form1 : Form
    {
        public form1()
        {
            InitializeComponent();
        }

        public ListView MyListView
        {
            get
            {
                return taskList;
            }
        }

Form2:

public partial class form2 : Form
    {
        public form2()
        {
            InitializeComponent();
        }

        form1 f;

        public add(form1 f)
        {
            this.f = f;
        }        

        public void AddToList()
        {
                ListViewItem item1 = new ListViewItem(txtName.Text);
                item1.SubItems.Add(txtEmail.Text);
                item1.SubItems.Add(txtPhone.Text);
                f.MyListView.Items.AddRange(new ListViewItem[] { item1 });
        }
  • 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-15T12:40:44+00:00Added an answer on May 15, 2026 at 12:40 pm

    The most straight forward way of doing things would be to use events. You could add an event on form2 that would fire each time an item is added, and includes the text to be inserted (you have multiple pieces of information, so a custom data type would be appropriate). You can then add a handler method to form2 which adds the item to its ListView. You then tie the two together in the code that is creating the two forms, and life should be good.

    So, to provide some code, First up is the data structure for the event:

    public delegate void HandleItemAdded(object sender, ItemAddedEventArgs e);    
    
    public struct ItemAddedEventArgs : EventArgs
    {
        public string Name;
        public string Email;
        public string Phone;
    
        public ItemAddedEventArgs(string name, string email, string phone)
        {
            Name = name;
            Email = email;
            Phone = phone;
        }
    }
    

    Then we have the event code on form2

    public event HandleItemAdded ItemAdded;
    // .. some other stuff
    public void RaiseItemAdded(ItemAddedEventArgs e)
    {
        if(ItemAdded != null)
            ItemAdded(this,e);
    }
    
    // ... now for your AddToList
    public void AddToList()
    {
    
        RaiseItemAdded(new ItemAddedEventArgs(txtName.Text,txtEmail.Text, txtPhone.Text);
    }
    

    And now we can add a handler in form1

    public void HandleItemAdded(object sender, ItemAddedEventArgs e)
    {
        ListViewItem item1 = new ListViewItem(txtName.Text);
        item1.SubItems.Add(txtEmail.Text);
        item1.SubItems.Add(txtPhone.Text);
        MyListView.Add(item1);
    }
    

    And last but not least we need to tie them together

    //...not sure what your code looks like, but we'll assume we have instances of the two forms named form1Form and form2Form
    form2Form.ItemAdded += form1Form.HandleItemAdded
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering how I can programmatically update a Core Data object. The object
I have a page where you can update a lot of data, I'm wondering
I am very new to Ruby, and was wondering how I can update the
I was wondering how GMail and things like that can update the emails in
I was just wondering how I can animate the jQuery form ui's div update
i'm wondering how can I compare in C language, a number I put on
I was wondering if there is a way I can update my Android application
I am wondering if I can update a column with some finite TTL to
Good Day all, I have an existing site built. I was wondering, how can
Wondering why I can't get document.getElementById("my_div").innerHTML to update the DOM when I re-assign the

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.