Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb.net, listbox header

Posted on 2014-11-13
2
Medium Priority
?
1,541 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
[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
2 Comments
 
LVL 11

Assisted Solution

by:Deepak Lakkad
Deepak Lakkad earned 600 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 1400 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

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 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