943,602 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 6464
  • VB.NET RSS
Mar 31st, 2009
0

Multi Column List Boxes

Expand Post »
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.
Similar Threads
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
jhonnyboy is offline Offline
97 posts
since Jul 2008
Mar 31st, 2009
0

Re: Multi Column List Boxes

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
VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Mar 31st, 2009
0

Re: Multi Column List Boxes

Thank you for your fast response!
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
jhonnyboy is offline Offline
97 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: StreamWriter Is Overriding Already Written Items in File
Next Thread in VB.NET Forum Timeline: Starting a Program using VB Module





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC