Listbox diferente
como eu faço para que quando o meu mouse passar por um dos itens de um listbox mudar de cor
Anicetojunior
Curtidas 0
Respostas
Beppe
24/09/2004
Isto vai em public: ItemCorrente: Integer;
ListBox1.Style := lbsOwnerDrawFixed; // ou lbsOwnerDrawVariable
E configure estes eventos:
ListBox1.Style := lbsOwnerDrawFixed; // ou lbsOwnerDrawVariable
E configure estes eventos:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin with TListBox(Control), Canvas do begin if Index = ItemCorrente then Brush.Color := clGreen; FillRect(Rect); TextOut(Rect.Left, Rect.Top, Items[Index]); end; end; procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var NovoItem: Integer; begin with TListBox(Sender) do begin NovoItem := ItemAtPos(ScreenToClient(Mouse.CursorPos), True); if NovoItem <> ItemCorrente then begin ItemCorrente := NovoItem; TListBox(Sender).Invalidate; end; end; end;
GOSTEI 0
Anicetojunior
24/09/2004
VALEU D++++++++++++,obrigadaooooooooooooooo,
GOSTEI 0