Solved

horizontly scroll my headers, when I scroll my listbox using the scroll bar of the listbox

Posted on 1998-08-27
2
317 Views
Last Modified: 2010-04-15
I am adding columnar data to a listbox with fixed pitch font. Now I need to put headers to describe the columns. How do I horizontly scroll my headers, when I scroll my listbox using the scroll bar of the listbox?
0
Comment
Question by:rferrell
2 Comments
 
LVL 4

Accepted Solution

by:
emmons earned 100 total points
ID: 1252331
1: This should be in the Windows section, not the C section.
2: If you add a handler for scroll message in the list box, and then send a scroll message to the header whenever the body scrolls, you should be able to keep them in synch.

0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1252332
My alternative solutions

1. Switch to ListView control (CListCtrl in MFC) if using 32 bit windows.  This may unfortunately avoid some significant code rewriting

or

2. Make the listbox owner draw (LBS_OWNERDRAWFIXED style) and handle the WM_DRAWITEM messages

In Draw item test if the item being drawn is the top visible line, if it is draw the headers instead of the real item.  You will loose a line from the listbox as a result of this, so insert extra dummy items.

This isn't a very good solution but can be made to work reasonably well.

or

3. Create a header control above the listbox (i.e. don't actually put the headers in the list).  When you scroll the list box, update the header control to match


#1 or #3 are the best solutions in my view, and involve the least code.  If you are in Win32 you really should consider #1 as the ListView control is much better for this kind of thing than the ListBox.


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

730 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