Custom Controls (Checkbox / List)

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 6
Reputation: corteplaneta is an unknown quantity at this point 
Solved Threads: 0
corteplaneta corteplaneta is offline Offline
Newbie Poster

Custom Controls (Checkbox / List)

 
0
  #1
Oct 14th, 2008
Hi, I'm not too experienced with .NET programming, but I was wondering if anyone knows of a custom control in VB.NET that involves a list (sort of like a ListBox), with at least 2 columns, and the ability to select individual members of this list. I basically have a dynamic NameValueCollection I would like to populate this list with and allow users to select different items.

Does anyone know of a pre-made control like this?
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: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Custom Controls (Checkbox / List)

 
0
  #2
Oct 14th, 2008
You'll get that with ListView control.
Fill ListView control:
  1. Dim TempStr(1) As String
  2. Dim NewNode As ListViewItem
  3. ListView1.View = View.Details
  4. ' FullRowSelect has to be True
  5. ListView1.FullRowSelect = True
  6. ListView1.Columns.Clear()
  7. ListView1.Columns.Add("Column1", 100)
  8. ListView1.Columns.Add("Column2", 100)
  9. ListView1.Items.Clear()
  10. TempStr(0) = "foo"
  11. TempStr(1) = "bar"
  12. NewNode = New ListViewItem(TempStr)
  13. ListView1.Items.Add(NewNode)
  14. TempStr(0) = "another"
  15. TempStr(1) = "item"
  16. NewNode = New ListViewItem(TempStr)
  17. ListView1.Items.Add(NewNode)
and check where the mouse was clicked:
  1. Private Sub ListView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
  2. Dim HTInfo As ListViewHitTestInfo = ListView1.HitTest(e.Location)
  3. Dim TempStr As String
  4. HTInfo = ListView1.HitTest(e.Location)
  5. TempStr = HTInfo.SubItem.ToString
  6. MessageBox.Show(TempStr, _
  7. "SubItem", _
  8. MessageBoxButtons.OK, _
  9. MessageBoxIcon.Information)
  10. End Sub
Of course you can have more than two columns if you need.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 6
Reputation: corteplaneta is an unknown quantity at this point 
Solved Threads: 0
corteplaneta corteplaneta is offline Offline
Newbie Poster

Re: Custom Controls (Checkbox / List)

 
0
  #3
Oct 15th, 2008
Thanks!
Reply With Quote Quick reply to this message  
Reply

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



Other Threads in the VB.NET Forum
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