Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default ListBox Headings - customized!

There have been many requests and responses regarding how to add
headings to a ListBox with multiple columns. Most assume that both
the data and headings are on a worksheet. It has been pointed out
(correctly) that it is not possible to add headings if data is to be
added programmatically, ie using the AddItem and List methods (an
oversight by MS?).

But there is an easy way, or more correctly, a workaround which avoids
using a worksheet and RowSource property - something I desired when
working with a collection class (I did not want to have to write it
first to the worksheet - ugly).

As a bonus, the heading background can be customised to give a
professional look different from the data (background color, font
color, border style). It is therefore useful even if data does come
from the spreadsheet (using RowSource property).

Wow, how can this be?!

Very simply, create another listbox (say lstHeader) for the headings!

1. Place the lstHeader directly above the data listbox (say lstData)
with borders overlapping. I have found the flat look with borderstyle
= line looks good.
2. Set both listboxes to ColumnHeads = False
3. Resize height of lstHeader to accomodate only one row
4. Set ColumnCount and ColumnWidth properties for lstHeader equal to
that of lstData. Note though that if lstData has ListStyle property =
fmListStyleOption, you must add an additional blank heading column at
the beginning of lstHeading with an appropriate width (12pt seems
about right).
5. Change the color and font properties of lstHeader as you like.

I have found this requires a bit of jiggling of the controls on the
form to get it to work and look right. But it works beautifully for
me. Hope you all find likewise.

Cheers
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default ListBox Headings - customized!

Here's a suggestion: write a class that takes two listboxes as
parameters and changes the properties of the 'headers' listbox
relative to the 'main' listbox. As you say, it required a bit of
jiggling to get right, so write that class now to save yourself the
bother of all that jiggling next time. Post it here and soak up the
kudos.

Jamie.

--
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet has numeric column headings. Change to alpha headings? Be Frank Excel Discussion (Misc queries) 1 June 18th 08 04:22 PM
(repost) Listbox Rowsource Headings Multi columns hgdev Excel Programming 1 April 13th 04 07:08 PM
Listbox Rowsource Headings Multi columns Copy Range If Then Conditional hgdev Excel Programming 0 February 27th 04 05:27 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"