Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / February 2005

Tip: Looking for answers? Try searching our database.

Converting VB ListBox to ListView in VB.net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Pyle - 09 Feb 2005 19:57 GMT
I have an application that I am converting to vb,net. I use a list box with
multiple columns that I reference using the "list" function. How do I do this
in vb.net? The list box looks like this:

Col1     Col2   Col3
C11     C21    C31
C12     C22    C23
...

How do I build it?
How do I reference a specific column when a row is selected?
Michelle@bwalk.com - 09 Feb 2005 21:06 GMT
Hi John,

A list view will definately work for this.  Here's an example of how I
programmically build a list view:

  _____________________
  lvwQuickView.BeginUpdate()

  lvwList1.Columns.Add("Col1", 50, HorizontalAlignment.Left)
  lvwList1.Columns.Add("Col2", 75, HorizontalAlignment.Left)
  lvwList1.Columns.Add("Col3", 75, HorizontalAlignment.Left)

  For Each tmpRecord In myCollection
        Dim item As ListViewItem
        item = lvwList1.Items.Add(New ListViewItem(New String(2)
{info1, info2, info3}))
        item.Tag = tmpRecord
  Next

  lvwQuickView.EndUpdate()
  _____________________

To reference individual columns when a row is selected:

      lvwList1.SelectedItems(0).SubItems(0).Text

I hope this helps.

Michelle
John Pyle - 09 Feb 2005 21:31 GMT
This helps greatly.

After the list is built is tthere a way to select the first row. Like the
old ...Index=0?

> Hi John,
>
[quoted text clipped - 25 lines]
>
> Michelle
Michelle@bwalk.com - 09 Feb 2005 21:39 GMT
Yup, you should be able to use something like this:

    lvwList1.Items(0).SubItems(0).Text

Take Care!
Michelle

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.