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
 
Back
Top