Solved

Listboxes VB.NET

Posted on 2013-06-10
3
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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