473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Converting VB ListBox to ListView in VB.net

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?
Nov 22 '05 #1
3 1847
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

Nov 22 '05 #2
This helps greatly.

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

"Mi******@bwalk.com" wrote:
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

Nov 22 '05 #3
Yup, you should be able to use something like this:

lvwList1.Items(0).SubItems(0).Text
Take Care!
Michelle

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mad | last post by:
Hello to all, I am new to vb6 and I have been trying to make a listbox with a horizontal and vertical scrollbar. For example, like the one on the program Address book that is found on all Windows...
4
by: Bernie Yaeger | last post by:
I now know how to gather the file type icons and I'm able to use them in a listview. But a listbox does not have a .smallimagelist or .largeimagelist member, so I don't know how to translate that...
2
by: Kanaiya | last post by:
hello how to put images in either listbox or listview.bye. -- With regards, Gangani Kanaiya.
3
by: Chris | last post by:
I'm able to add a context menu to the right click on a listbox but it does not select the item in the listbox. I would like the context menu before it pops up to select the item that the mouse was...
2
by: John R. | last post by:
I want to have a listbox that shows a checkbox and a textbox. I created a user control that has a checkbox and a textbox in it and have been trying to add it to a listbox but I can't get it to...
4
by: CR | last post by:
In VB6 if I wanted to display a group of records, and possibly allow the user to select one or more records, I would use the ListBox. For example suppose I wanted to display something like this: ...
1
by: Melson | last post by:
Hi May I know what is the differences between vb.net listbox and listview. When should I use listbox or listview. Regards Melson
3
by: thomasp | last post by:
Has anyone got some sample code to do drag and drop from one listbox to another listbox using VB.Net 2005. The below code works for draging and droping one at a time, but not for multiselected...
1
by: The Confessor | last post by:
I currently have a listbox in my program which I populate with data from a random access file as follows: For T = 1 To HighestPointID FileGet(1, Point(T), T) ListBox_Point.Items.Add(T & " Lat:...
2
by: markliam | last post by:
I have a ListBox that is displaying a formatted string based on the contents of a DataSet. The purpose of the listbox is for the user to select an entry to delete, but I'm not sure how to match...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.