Multicolumn ListBox

  • Thread starter Thread starter Mazin Al-Noaimi
  • Start date Start date
M

Mazin Al-Noaimi

Hi all,

I want to add three values each time to the list box to be as one record

for example

I have first name, last name, phone number values
I want to add them to a listbox once to be three column

so can any body help in this particle code ....
 
Hi

First of all you need to set the ListView propery View to Details. With the following code you can add columns (headers)

listView1.Columns.Add("First name", 150, HorizontalAlignment.Left)
listView1.Columns.Add("Last name", 150, HorizontalAlignment.Left)
listView1.Columns.Add("Phone number", 150, HorizontalAlignment.Left)

And with this code you can add data to the listview:

ListViewItem item = new ListViewItem()

item.Text = "John";
item.SubItems.Add ("Doe")
item.SubItems.Add ("000000000")

listView1.Items.Add (item);

Hope it helps

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top