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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:47:34+00:00 2026-05-28T15:47:34+00:00

Hi i have a listview with diffrent columns ID, Name, Zipcode, City, Country, Phone,

  • 0

Hi i have a listview with diffrent columns ID, Name, Zipcode, City, Country, Phone, Email
And i have two Forms, Form1 and Form2

In the First form i have the listview with the columns
On the second Form i have a Custom manager with diffrent Listboxes where you can type in the customer information (ex Name, Zipcode, City, etc)

I want the information in Form2 to be sorted after the columns in Form1. ex the “name” Texbox in Form2 should be inserted in Form1 listview under the column Name, and The textbox Zipcode text should be inserted under the Zipcode column.

picture http://img717.imageshack.us/img717/3486/skiten1.png

It’s hard because im little bit of a beginner and to follow diffrent sites didn’t help me.

Please what can i do.

Form1

InitializeComponent();


listView1.View = View.Details;
listView1.LabelEdit = true;
listView1.AllowColumnReorder = true;
listView1.FullRowSelect = true;
listView1.GridLines = true;
listView1.Sorting = SortOrder.Ascending;

listView1.FullRowSelect = true;
listView1.Columns.Add("ID", 300, HorizontalAlignment.Left);
listView1.Columns.Add("Name", 70, HorizontalAlignment.Left);
listView1.Columns.Add("Zipcode", 70, HorizontalAlignment.Left);
listView1.Columns.Add("City", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Country", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Phone", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Email", 100, HorizontalAlignment.Left);

Form2

private void btnOk_Click(object sender, EventArgs e)
       {
           contact.FirstName = tbFirstName.Text;
           firstName = contact.FirstName;

           contact.LastName = tbLastName.Text;
           lastName = contact.LastName;

Form2

private void btnOk_Click(object sender, EventArgs e)
        {
            MainForm main = new MainForm();

            contact.FirstName = tbFirstName.Text;
            firstName = contact.FirstName;

            contact.LastName = tbLastName.Text;
            lastName = contact.LastName;

still Form2

 public override string ToString()
    {
        return string.Format("[{0}]", contact.ToString());

    }

//Here comes the Contact class

class Contact
    {
    private string firstName;
    private string lastName

In the Contact class there is also properties of the above variables and then a ToString like this

public override string ToString()
        {
            return string.Format("[{0}, {1}, {2}, {3}]", firstName, lastName);


        }

Form1

private void MainForm_Load(object sender, EventArgs e)
        {
            ColumnHeader columnheader;
            ListViewItem listviewitem;

            // Ensure that the view is set to show details.
            listView1.View = View.Details;
if (customerframe.ShowDialog() == DialogResult.OK) //if button OK is clicked then value will be inserted
            {
                listviewitem = new ListViewItem(contact.FirstName);
                listviewitem.SubItems.Add(contact.LastName);
this.listView1.Items.Add(listviewitem);

I dont really know know how much code you need for helping me, moreover, my code is very messy

  • 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-28T15:47:35+00:00Added an answer on May 28, 2026 at 3:47 pm

    That’s not exactly “sorting” in the traditional sense. You are just trying to add a ListViewItem into the ListView control and then add more information into that ListViewItem’s SubItems.

    An example would look something like this:

    ListViewItem lvi = new ListViewItem(yourID);
    lvi.SubItems.Add(contact.Fullname);
    lvi.SubItems.Add(zipcode);
    lvi.SubItems.Add(city);
    lvi.SubItems.Add(address.country);
    lvi.SubItems.Add(phone);
    lvi.SubItems.Add(email);
    
    listView1.Items.Add(lvi);
    

    Update:

    Your customerFrame class (Form2) doesn’t look like it has the reference to your Contact reference.

    Your customerFrame return a Contact object with the data filled out. Something like this:

    Public Contact GetContact() {
      Contact contact = new Contact();
      contact.FirstName = tbFirstName.Text;
      // etc.
      return contact;
    }
    

    And then your Form1 call should look something like this:

    using (var customerFrame = new CustomerFrame()) {
      if (customerFrame.ShowDialog() == DialogResult.OK) {
        Contact contact = customerFrame.GetContact();
    
        listviewitem = new ListViewItem(contact.FirstName);
        listviewitem.SubItems.Add(contact.LastName);
        // etc.
        this.listView1.Items.Add(listviewitem);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have to add two columns in a ListView . One column shows different
I have an Arraylist of HashMap . Each HashMap element contains two columns: column
I have a listview with two labels, title and subtitle. I want to have
In WPF app I have a ListView : <ListView Height=100 Width=434 x:Name=lvItems ItemsSource={Binding ElementName=MainWindow,
I have the follwoing listview in my xaml: <ListView Name=listView1> <ListView.View> <GridView> <GridViewColumn Width=Auto
I have a listview with different layouts for all the listitems. My first listitem
I have a ListView that contains two types of objects, single and multiple. The
I have a RelativeLayout with different elements. I was planning to have two ListViews
I have a page with two Listviews (with two different data sources). I have

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.