Solved

Listboxes VB.NET

Posted on 2013-06-10
3
263 Views
Last Modified: 2013-06-12
I am very new to VB.NET.  I have approx. 6+ years with VB6 and VBA.  I have just turned to VB.NET approx. 2 weeks ago and I have gotten a connection to my sql server.  I know how to retrieve data.  The problem I am having is showing records in a ListBox with columns and column heads.  I have gotten it to show 1 column and if I click on the row, it goes to the record, but I can not figure out how to make it show more than one column and how to make it show column heads.  I am using VB.NET 2012.  Any help would be greatly appreciated.  Also if you have an suggestions as to resources please tell me.  I have gotten a very decent book, but it doesn't cover this.  Thanks in advance!
0
Comment
Question by:russell12
3 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 39234063
instead of listbox use ListView,
in the properties pane u can add columns and change different properties of the listview like FullRowSelect, GridLines, BackColor etc.

check this tutorial:
http://www.tutorialspoint.com/vb.net/vb.net_listview.htm
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 250 total points
ID: 39234624
The ListBox does not enable multiple columns and headers. If you really need those, use a ListView as suggested by sedgwick.

But the ListBox takes less space in the Form and requires less resources than a ListView.

Columns header are very often useless, because most user will recognize the information by its content. If you do not really need the column headers, you can often use a concatenation in the stored procedure or SQL statement in order to display the values of 2 database columns in the single column of a ListBox.

As an example, a LastName and FirstName fields can be concatenated into one that displays

Doe, John
Burger, James

An Address, City, State and ZipCode combination can also be concatened to something like the following.

123 MyStreet, New York, NY 12345
456 YourStreet, Albany, NY 45678

This can be displayed in the ListBox single column.
0
 
LVL 2

Author Closing Comment

by:russell12
ID: 39242585
Thanks for both of your inputs, they were both very helpful informational!
Russell
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question