Solved

vb.net, listbox header

Posted on 2014-11-13
2
1,090 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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

9 Experts available now in Live!

Get 1:1 Help Now