Solved

Listbox Multi-Select Without Ctrl Key

Posted on 2004-10-20
3
1,629 Views
Last Modified: 2008-01-09
When a Listbox is set to multi-select, I know you can select/deselect individual items by single-clicking on them with the Ctrl key held down.

Is it possible to do it without using the Ctrl key - for example when using a touch sensitive screen when a keyboard isn't available?

I have a button on the form which acts as a toggle. Using this button's Tag property I can effectively turn a 'virtual' Ctrl key on and off, but I'm not sure how to go about acting on this toggle to select/deselect items on the list.

(For those of you not familiar with touch screens, a finger press on the screen simply generates a single mouse click at that screen X/Y position).

I've tried using the OnMouseDown event using an If...Then to check if the button Tag property is 0 or 1, but a single click still deselects all the other items.

Any suggestions please?

TDK_Man
0
Comment
Question by:tdk_man
[X]
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
3 Comments
 
LVL 1

Accepted Solution

by:
vacerose earned 125 total points
ID: 12358629
Try setting the listbox "ExtendedSelect" property to false.

Following was taken from delphi help

If ExtendedSelect is false and MultiSelect is true, the user can select multiple items without using the Shift or Ctrl key, but they can’t select a range of items in one operation.

For more details, lookup help on TListBox and see the ExtendedSelect property.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12358648
I'm not sure. Is the Listbox.Selected[] property readonly? I don't think it is so you could just set it yourself. Maybe change the OnClick behaviour too then. But as an alternative, Delphi 7 offers a CheckListbox where you can check and uncheck items instead of selecting them. Might be easier?
0
 
LVL 1

Author Comment

by:tdk_man
ID: 12358770
Well I'll be!...

You are correct vacerose - it was that simple!

You apparently learn something new every day, so I can go back to being braindead for the rest of this one!  :)

Thanks far that...

Alex:

I'm using V5 and the Listbox.Selected[] property isn't readonly - I was just finding it impossible to over-ride the component's natural tendency to deselect all items on single clicking.

I even tried creating a boolean array and storing all of the listbox items Selected properties then setting them all at the end of the routine - which didn't work either.

Not to worry now though, simply setting ExtendedSelect  to False did the trick!

TDK_Man
0

Featured Post

Technology Partners: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 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