?
Solved

Listbox Multi-Select Without Ctrl Key

Posted on 2004-10-20
3
Medium Priority
?
1,656 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 500 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

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month8 days, 9 hours left to enroll

764 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