Discussion:
Listboxes Dataviews and Scrollbars
(too old to reply)
mick
2009-09-16 23:18:30 UTC
Permalink
I have a listbox whose Datasource is a DataView. When all of the items
appear in the listbox a horizontal scrollbar appears because some of them
are wider that the listbox (as it should of course).

Now if apply a filter to the Dataview the listbox still displays a scrollbar
even if the newly filtered items now fit in the listbox. Anyone know why and
how to stop it? Shouldnt it be automatic?

I`ve tried lb.Refresh() and lb.Invalidate() but that does nothing.

TIA,

mick
Scott M.
2009-11-13 00:04:35 UTC
Permalink
Does this help:

ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system.windows.forms/html/1b677fe7-fa4d-e282-cd2d-2aa8b365775b.htm


ListBox..::.HorizontalExtent Property

This property only reports a useful value if the HorizontalScrollbar
property is set to true. If the width of the ListBox is smaller than the
value of this property, the horizontal scroll bar horizontally scrolls items
in the ListBox. If the width of the ListBox is equal to or greater than this
value, the horizontal scroll bar is hidden. The value of this property is
not dynamically updated by the ListBox. This property is useful when the
items of the ListBox are owner-drawn. For example, if the owner drawn items
of the ListBox are 200 pixels wide, but the ListBox is 60 pixels wide, the
HorizontalExtent property would need to be set to 200 in order to scroll the
right edge of the items into the visible region of the control.

-Scott
Post by mick
I have a listbox whose Datasource is a DataView. When all of the items
appear in the listbox a horizontal scrollbar appears because some of them
are wider that the listbox (as it should of course).
Now if apply a filter to the Dataview the listbox still displays a
scrollbar even if the newly filtered items now fit in the listbox. Anyone
know why and how to stop it? Shouldnt it be automatic?
I`ve tried lb.Refresh() and lb.Invalidate() but that does nothing.
TIA,
mick
Loading...