Solved

Listboxes VB.NET

Posted on 2013-06-10
3
262 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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