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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:39:14+00:00 2026-06-08T16:39:14+00:00

Guys i’m a beginner in implementing ListView in c#. I’m having a problem with

  • 0

Guys i’m a beginner in implementing ListView in c#. I’m having a problem with these piece of code in c#.net. And I can’t figure out whats happening in the control shown by the output. It seems i forgot something to give a value in properties of ListView Control.

2nd column values must appear on the first column.

enter image description here

This is my code:

using System;
using System.Collections.Generic;   
using System.ComponentModel;
using System.Data;                  
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;        
using System.Data.OleDb;            
namespace Database2
{
    public partial class Form1 : Form
    {
        OleDbConnection con;
        OleDbDataAdapter adapter;
        DataTable table;

        string conString = "Provider = Microsoft.Jet.OLEDB.4.0.; Data Source=DatabaseTest.mdb";
        string sqlQuery = "SELECT * FROM Person";

        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e){
            con = new OleDbConnection(conString);
            adapter = new OleDbDataAdapter(sqlQuery,conString);
            table = new DataTable();

            InitializeList();

            adapter.Fill(table);

            for (int i = 0; i < table.Columns.Count; i++)
                lstDisplay.Columns.Add(table.Columns[i].ColumnName.ToString(), lstDisplay.Width / 6-1);

            for (int i = 0; i < table.Rows.Count; i++) { 
                ListViewItem row = new ListViewItem();
               for (int j = 0; j < table.Columns.Count; j++)
                    row.SubItems.Add(table.Rows[i][j].ToString());
               lstDisplay.Items.Add(row);
            }
        }

        private void InitializeList() {
            lstDisplay.GridLines = true;
            lstDisplay.AllowColumnReorder = true;
            lstDisplay.LabelEdit = true;
            lstDisplay.FullRowSelect = true;
            lstDisplay.Sorting = SortOrder.Ascending;
            lstDisplay.View = View.Details;
        }
    }
}

Is there a listView property i forgot to give a value?

  • 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-08T16:39:16+00:00Added an answer on June 8, 2026 at 4:39 pm

    The ListViewItem itself represents the first column. Subsequent columns are represented by ListViewSubItems.

    Ex:

    for (int i = 0; i < table.Rows.Count; i++)
    { 
       ListViewItem row = new ListViewItem(table.Rows[i][0].ToString());
       for (int j = 1; j < table.Columns.Count; j++)
          row.SubItems.Add(table.Rows[i][j].ToString());
       lstDisplay.Items.Add(row);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

guys am having some troubles with running out of memory when displaying an animation
Guys, I've came across this problem I can't resolve myselg, I'm pretty sure I
Guys, this can't be for real I'm trying to make a .NET 2.0 executable
guys! I have problem with my .net application. When I try to print in
guys, I would like to you evaluate next code below. As you see, I
guys. I have a strange problem. I try to write unit-tests to web-app. I
Guys, what is function called after my class loaded, where i can call self
guys. I have UITableView with different cells and I have code, which counts height.
guys. I have two view controllers with two uiwebviews. Here is my code: First
Guys i am facing a problem with wildcard character in jquery. Please help 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.