ListBox - fundo amarelo (selecao)

Top  Previous  Next

Listbox com fundo amarelo:

 

procedure TForm1.ListBoxDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);

begin

  with (Control as TListBox).Canvas do

  begin

    Brush.Color := clWindow;

    if (State = [odSelected,odFocused]) then Brush.Color := clYellow;

    FillRect(Rect);

    Font.Color := clBlack;

    TextOut(Rect.Left + 2, Rect.Top, (Control as TListBox).Items[Index]);

  end;

end;

 

 

NAO ESQUECA:

 

Style == lbOwnerDrawFixed