PDA

View Full Version : Listbox with zero entries



shankar
11-21-2009, 09:36 AM
I want to have a listbox in a Windows form which needs to have a header row. But it should allow the option of having zero entries. However this is not possible, since I have to specify at least one row for RowSource to display the header (the row above the first row of the range).

So how is it possible to have zero entries in the list? Right now I am setting the first row of RowSource as a blank and Enabled property to false if there are zero entries to be displayed. But I am wondering if there is a better way. Thanks.

Shankar

mdmackillop
11-21-2009, 10:55 AM
This uses a dynamic range name as the row source. Counting the Header to form the range size provides the range which allows the header to be displayed.

drawworkhome
11-21-2009, 01:36 PM
mdmackillop;
cool feature.
erik

shankar
11-21-2009, 08:45 PM
Thanks, but there is a blank row that is selectable in your example. Is there a way to make no row selectable, other than by disabling the control?

mdmackillop
11-22-2009, 03:49 AM
I wouldn't think so. What is the problem with doing that?

drawworkhome
11-22-2009, 08:24 AM
is there a way manually place text in the columnhead via code (vba)?

mdmackillop
11-22-2009, 09:30 AM
I don't believe so, other than by changing it in the rowsource.

drawworkhome
11-22-2009, 09:34 AM
thats what i think also. i tried like heck last night and couldnt find/discover a way to do it.

erik

mdmackillop
11-22-2009, 11:36 AM
Why not add a textbox immediately above the Listbox?

drawworkhome
11-22-2009, 03:44 PM
that is what i currently have. i am a newbie, so am learning all i can.
erik