Solved

vb.net, listbox header

Posted on 2014-11-13
2
1,198 Views
Last Modified: 2014-11-14
On a vb.net winform below, A is what I have.
Question: Is it possible to make changes to the header area, as shown on B above?
headerLike:
1. Add a continuous line under header captions.
2. Make header text bold, change its size, etc.

The code populating this listbox is:
      lstCustomers.Items.Add("Cust ID" & ControlChars.Tab & "F. Name" & ControlChars.Tab & _
                               "L. Name" & ControlChars.Tab & "City" & ControlChars.Tab & "State")

        lstCustomers.Items.Add("-------" & ControlChars.Tab & "-------" & ControlChars.Tab & _
                               "-------" & ControlChars.Tab & "-------" & ControlChars.Tab & "-------")

        ' ADD CUSTOMERS TO lstCustomers
        For Each customer In customers
            lstCustomers.Items.Add(customer.CustomerID & ControlChars.Tab & _
                                                      customer.FirstName & ControlChars.Tab & _
                                                      customer.LastName & ControlChars.Tab & _
                                                      customer.State & ControlChars.Tab & _
                                                      customer.City)
        Next

Open in new window

0
Comment
Question by:Mike Eghtebas
2 Comments
 
LVL 11

Assisted Solution

by:Deepak Lakkad
Deepak Lakkad earned 150 total points
ID: 40441982
Hi,

At present, you are using ListBox control to show list of records.

You can use ListView Control to get desired result.

- Deepak Lakkad
0
 
LVL 11

Accepted Solution

by:
LordWabbit earned 350 total points
ID: 40442372
As Deepak said, you can get that using a listview instead of a listbox.  You set the columns in the properties (and their sizes) and change the View property of the listview to Details.  
Then when adding the customers you create a list view item whose value will be in the first column, and then for each subsequent column you add a sub item.  Like this...

        Dim customers As New List(Of Customer)
        customers = db.Customers.ToList()
        For Each customer As Customer In customers
            Dim cust As New ListViewItem(customer.CustomerID)
            cust.SubItems.Add(customer.FirstName)
            cust.SubItems.Add(customer.LastName)
            cust.SubItems.Add(customer.State)
            lstCustomers.Items.Add(cust)
        Next

Open in new window


Which will give you something that is closer to what you want.
EE-Untitled.png
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question! 4 36
Reference issues in Visual Studio 3 29
Reading the web config for a running service on Windows 10 16 39
REXEX help Part 2 2 22
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 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

12 Experts available now in Live!

Get 1:1 Help Now