Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add columns to the ListBox 1

Status
Not open for further replies.

Jsd02

Programmer
Apr 21, 2002
12
EE
I need a listbox with columns, you know columns like in kazaa when you're in the traffic screen you see a listbox with columns "title", "artist", "user" etc. How to do that?
 
A listbox only contains one column. For multi-column lists, you want a ListView control. To create one, just drop one on the form from the toolbox.

To add columns to it, you call the Add method:
Code:
listView1.Columns.Add("Column Name", -2, HorizontalAlignment.Left)

The -2 means to autosize the column to the size of the header text. You can also pass in a -1, which means to autosize the column to the width of the largest subitem text in the column. The HorizonatalAlignment should be self-explanatory.

To add items to the listview, you can call the AddRange method, or work your way through the Items collection:
Code:
ListViewItem MyItem = listView1.Items.Add("Item1");
MyItem.SubItems.Add("SubItem1");
MyItem.SubItems.Add("SubItem2");

Chip H.
 
another question about listview. How to change the views of the listview? I need "detailed" view
 
that was very helpful, thanks a lot!
 
I would like to know, how a hidden column ( zero lenght ) could be really unabled to the user's view.
 
Hi,
I have read line by line and have search for a particular word using regex, when it has found this word i have sent this line to a function because i want to read this particular line by each character. My question is the file is in .rtf, how can y keep the format of this particular line? Its just sending a bunch of text characters.
well Is there a better way for me to do this ?
any suggestions?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top