Solved

Listboxes VB.NET

Posted on 2013-06-10
3
257 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for both of your inputs, they were both very helpful informational!
Russell
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now