MS Visual C++ .... retrieving List Box selection

Posted on 2003-03-18
Medium Priority
Last Modified: 2013-12-13
To clarify...this is not a Dropdown, or combo box, but a list box with the Up/Down arrows to the right.

I have found that if I scroll through the box and stop on the desired selection from the list, that the selection is not assigned to the control's variable unless you actually click on the selection (and it changes colors). So a user, using only the arrows to find the desired selection, could stop at the right choice, and from all appearances, think that the displayed value will be submitted, but the selection actually didn't 'take'.

If there another EVENT that can be monitored for a selection made only by using the arrows? The "OnSelchange..." event is only invoked when the user actually clicks inside the box on the selection.

Incidentally, this is not the case with Dropdown lists (combo box). The "OnSelchange..." event function is executed without actually clicking the selection.

Question by:cox8355
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8169197
If the focus is inside the ListBox, which means there is a highlight bar inside it, keyboard navigation should produce selchange events.  If there is no highlighted bar, how could the user know what he or she is choosing?

Anyway, you could use GetTopIndex when the user clicks OK to get the first visible item in the listbox.


Author Comment

ID: 8176233
The user can change the displayed entry in the box by using the UP/DOWN scroll arrows. So the new selection is displayed, whether or not the user sets the focus inside the box by clicking on it.

The problem is, without clicking inside the box, (thus, no highlighted bar), the scrolled selection does not produce the "ONSELCHANGE" event, and the changed selection, though visible to the user, is not not addressed, since the function invoked by that event is not called. Is there an event just for the scrolling change, without clicking in the box? As is it, the user thinks a selection has been made, which is being ignored.

Accepted Solution

PlanetCpp earned 300 total points
ID: 8176362
you keep saying up/down arrows, are you talking about the standard scrollbar that's on the right of the listbox (if that style was indicated) or are you talking about the up/down arrows like the ones you can put into a textbox?
if you mean the latter then you must have put code to deal with the events coming from the arrow, post it.
i've never seen the up/down arrows added to a listbox though s  think you mean the regular scrollbar attached to it.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Make the most of your online learning experience.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Simple Linear Regression
Suggested Courses

777 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