we should use BeginUpdate and EndUpdate in order to ensure that the ListBox will not be repainted after each deletion. It is important to loop through the entries backwards (downto), because otherwise under circumstances we would access items in our loop that are no longer existing because we have deleted them before. Georgina Ramsamy will enlighten us about the three Selection components that you can use in Delphi including the List Box, the Combo box, and the Radio Groups. You may add items to the ListBox with Tab delimiter to. This time, we will have a deeper insight into some of the commonly used Selection components in Delphi. If yes, we are going through all items of the ListBox in order to delete them in the case that they are selected (in this case Selected is TRUE). AutoDrawTabbedText: Boolean When using AutoDrawTabbedText, you dont need to use objects or OnDrawItem. $2E is the virtual key code for the DEL key. Because we want to react to the DEL key, first of all, we are asking whether the key is $2E. The variable "Key" contains the pressed key. Today, I would like to show how to implement that a TListBox reacts to pressing the delete key (DEL) in Lazarus or Delphi and that accordingly, all selected entries will be removed from the list.įor that, we assign a OnKeyDown-Event to our listbox in which we are using the following code: procedure TForm1.ListBox1KeyDown(Sender: TObject var Key: Word įor i := - 1 downto 0 do begin
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |