Multi Column List Boxes

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Multi Column List Boxes

 
0
  #1
Mar 31st, 2009
Hello everyone. I would like to learn how to make a multi column list box. I have set the multi column Boolean to true and set the width but i have yet to see the two columns. I only see one.

I currently have a .csv file and in the format of:

Id, Name

I would like the listbox to have a column for Ids and Names. How would i be able to achieve this?
Last edited by jhonnyboy; Mar 31st, 2009 at 2:16 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 115
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Multi Column List Boxes

 
0
  #2
Mar 31st, 2009
Multi column listbox doesn't actually show items in multiple columns. It "wraps" items to the next column when you add them and the number of the items reaches the listbox's height.

If you want to show items in two columns, you'll have to use some grid control or listview control.

Here's an example with listview control
  1. Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. '
  3. Dim TempStr(1) As String
  4. Dim TempNode As ListViewItem
  5.  
  6. ' Show "hidden" text
  7. ListView1.ShowItemToolTips = True
  8. ' Set columnar mode
  9. ListView1.View = View.Details
  10. ' Set column header
  11. ListView1.Columns.Clear()
  12. ListView1.Columns.Add("UserID", 80)
  13. ListView1.Columns.Add("Name", 120)
  14. ' Remove previous items
  15. ListView1.Items.Clear()
  16. ' Add two items
  17. TempStr(0) = "1111"
  18. TempStr(1) = "Doe, John"
  19. TempNode = New ListViewItem(TempStr)
  20. ListView1.Items.Add(TempNode)
  21.  
  22. TempStr(0) = "2222"
  23. TempStr(1) = "Doe, Jane"
  24. TempNode = New ListViewItem(TempStr)
  25. ListView1.Items.Add(TempNode)
  26.  
  27. End Sub
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: Multi Column List Boxes

 
0
  #3
Mar 31st, 2009
Thank you for your fast response!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1336 | Replies: 2
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC