943,974 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3192
  • VB.NET RSS
Oct 14th, 2008
0

Custom Controls (Checkbox / List)

Expand Post »
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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
corteplaneta is offline Offline
6 posts
since Oct 2008
Oct 14th, 2008
0

Re: Custom Controls (Checkbox / List)

You'll get that with ListView control.
Fill ListView control:
VB.NET Syntax (Toggle Plain Text)
  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:
VB.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Oct 15th, 2008
0

Re: Custom Controls (Checkbox / List)

Thanks!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
corteplaneta is offline Offline
6 posts
since Oct 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: Incorrect Collating Sequence Error
Next Thread in VB.NET Forum Timeline: Crystal Report - Dynamic Design





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


Follow us on Twitter


© 2011 DaniWeb® LLC