RSS Forums RSS

Custom Controls (Checkbox / List)

Please support our VB.NET advertiser: DiscountASP.NET – 3 Months Free on VB.NET Web Hosting
Thread Solved
Reply
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)

  #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?
AddThis Social Bookmark Button
Reply With Quote  
Posts: 650
Reputation: Teme64 is on a distinguished road 
Solved Threads: 106
Teme64's Avatar
Teme64 Teme64 is offline Offline
Practically a Master Poster

Re: Custom Controls (Checkbox / List)

  #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  
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)

  #3  
Oct 15th, 2008
Thanks!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the VB.NET Forum
Views: 1441 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:59 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC