Solved

Listbox Multi-Select Without Ctrl Key

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now