tags:

views:

136

answers:

1

In widgets, I have a class named CListCtr which derived from wxHtmlListBox. The list contains 100 items, but I just want to show 10 items in one page and when I press button pagedown I will get another page to show another 10 items. I do not need the scrollbar. But it is always added when created the class. How can I delete the scrollbar or not create it?

A: 

wxHtmlListBox is a specialized wxVScrolledWindow, which handles the scrollbar itself. Naturally, when there are more list items in the list than can be shown at the same time in the client area, a scrollbar will appear.

Note however that there's nothing to say that your wxHtmlListBox needs to contain all available items. If you give it enough space for 10 items, just call SetItemCount(10) instead of SetItemCount(100), and you will get no scrollbar. You can handle the page up / page down or any other navigation keys yourself, and invalidate the contents of your wxHtmlListBox. Since it is a virtual control you don't need to change any data, you just return the next or previous 10 items in your list in the OnGetItem() and OnGetItemMarkup() methods of your derived class.

Please note that this is just an idea how to implement this, I think it's not a good thing to do. The scrollbar is the indicator that there is more data and where the user is relative to begin and end of the data. Don't break the assumptions the user has. How is he to know that page up / down will scroll the visible data?

mghie