[Lazarus] TListView - how to make selected line stay selected?
Bo Berglund
bo.berglund at gmail.com
Mon Aug 19 23:34:45 CEST 2019
On Mon, 19 Aug 2019 18:21:06 +0200, Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
>How can this be accomplished?
I ended up adding the code below after reading this:
http://delphidabbler.com/articles?article=16
procedure TfrmEditCuts.lvCutListCustomDrawItem(Sender:
TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
const
cStripe = $FF9933; // colour of selected list items
begin
if Item.Index = lvCutList.ItemIndex then
begin
lvCutList.Canvas.Brush.Color := cStripe;
lvCutList.Canvas.Font.Color := clWhite;
end
else
lvCutList.Canvas.Brush.Color := clWindow;
end;
This made the selected row stay colored even though the listview lost
focus when I clicked the buttons.
I had to probe the selection color in my paint program to set the
cStripe value to the same because when clicking on an item the
CustomDrawItem event seems not to be called. So on initial click the
row was colored blue and when I used my buttons to move the row it was
colored in the cStripe value that I originally used (light green).
Changing the cStripe value to the color of initial selection made the
row move without visible color change....
--
Bo Berglund
Developer in Sweden
More information about the lazarus
mailing list