Solved

Listbox Multi-Select Without Ctrl Key

Posted on 2004-10-20
3
1,608 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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