Author Topic: Buttons Multiselection  (Read 923 times)


  • Newbie
  • Posts: 3
Buttons Multiselection
« on: June 27, 2018, 11:27:07 am »
     Hi everyone  :) :)
     I've just started learning about lazarus and I have a problem:
     I created some buttons (button1, button2,...) and I want to make a multiselection of them. Particularly, I wanna press leftmouse button and 'Ctrl' on keyboard at the same time to click each button, or press 'Ctrl' + 'A' to select all of them. However, I actually don't know where I should start and also how to do that.
Could you give me some advice and the instruction to do that?
     Thank you so much and hope to see your feedback. Sorry for my poor English. :-\ :-\


  • Jr. Member
  • **
  • Posts: 88
Re: Buttons Multiselection
« Reply #1 on: June 27, 2018, 11:48:55 am »
Errr... why would you want a multi-select-option for command-buttons?
I understand multiselect, say in a listbox, but why for buttons?

Think about it:
You achieve your goal to select-multiple buttons in one go (either clicking consecutively with CTRL held down, or with a CTRL+A), then what?
Execute some code?
Execute the code within the Click-Events of each selected button? If Yes, in what order?
If you implement the multiselect in the usual way (aka what Endusers are used to), the moment you click on another button to execute something, all those selected buttons would lose its selection-status.
I'd think really hard if you really want to do something like that
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie


  • Hero Member
  • *****
  • Posts: 2879
Re: Buttons Multiselection
« Reply #2 on: June 27, 2018, 12:24:13 pm »
As Zvoni writes, only one button at a time can have focus, so Ctrl-A makes little sense.
Attached is a simple example to get you started.


  • Newbie
  • Posts: 3
Re: Buttons Multiselection
« Reply #3 on: June 27, 2018, 06:26:19 pm »
Thank you so much Zvoni and howardpc
Oh...I got it, actually this is a task in my exercise that we have to do some manipulations like doubleclick to create components, drag and drop them, and make multiselection of them and then delete the selected components. Firstly we choose buttons as the components we have done with, but it seems that it would be more suitable if I change into another kind of component. So is Image or Shape ok?


  • Newbie
  • Posts: 3
Re: Buttons Multiselection
« Reply #4 on: June 27, 2018, 07:05:12 pm »
Oh howardpc, sorry for missing your file. Thank you a lot.