TListView - how to deterimine selected column (without mouse!) lazarus / 31-LCL ---------------------------------------------------------------------- prof7bit · 2021-09-10 14:59 I have a TListView with style vsReport, it has multiple columns. When it has focus I can move around it with the arrow keys, not only up down through the rows but also left right through the columns. Now I want to press enter on the current selection and depending on which column I am in different things should happen. I already did this with doubleclick and with right click by using the mouse position and the column widths, but now (because I am keyboard centric and it would really speed up the workflow) i would also like to be able to start the double-click action with the enter key. But I cannot for the life of me figure out how to get the currently selected column from the listview! ---------------------------------------------------------------------- wp · 2021-09-10 15:38 Quote from: prof7bit on September 10, 2021, 04:59:43 pmWhen it has focus I can move around it with the arrow keys, not only up down through the rows but also left right through the columns. How do you achieve to move the selection into the subitem columns? ---------------------------------------------------------------------- prof7bit · 2021-09-10 17:08 Quote from: wp on September 10, 2021, 05:38:52 pmQuote from: prof7bit on September 10, 2021, 04:59:43 pmWhen it has focus I can move around it with the arrow keys, not only up down through the rows but also left right through the columns. How do you achieve to move the selection into the subitem columns? Oh, I just noticed it seems this is a Qt only thing! A few minutes ago I compiled it against GTK2 and I cannot move the selection horizontally at all. ---------------------------------------------------------------------- skalogryz · 2021-09-10 17:12 Quote from: prof7bit on September 10, 2021, 07:08:22 pmOh, I just noticed it seems this is a Qt only thing! A few minutes ago I compiled it against GTK2 and I cannot move the selection horizontally at all. Win32 can also do that. With some extra effort the similar functionality can be implemented on Cocoa. But that certainly turns ListView into GridView. Where it's no longer a list of items, but rather a matrix of data. Not a bad thing, if you ask me, but implementing on platforms without native support (i.e. Gtk2) might not be possible at all. As an initial implemented, I'd recommend to create some sort of the class helper that the method like GetSelectedColum() or GetSelectedRect(). ---------------------------------------------------------------------- prof7bit · 2021-09-10 17:29 Quote from: skalogryz on September 10, 2021, 07:12:57 pmBut that certainly turns ListView into GridView. Where it's no longer a list of items, but rather a matrix of data. I think I'm going to use a TStringGrid, because it actually really is a table of data and the user must clearly see which column he has clicked or selected because I have separate context menus and separate editors for separate columns, one of them even needs an entire form to edit and validate the value. ---------------------------------------------------------------------- skalogryz · 2021-09-10 17:37 Quote from: skalogryz on September 10, 2021, 07:12:57 pmWin32 can also do that. I'm wrong. win32 cannot do that either.