0

I have a Label on CategoryPanel and trying to change it's caption onMouseEnter and onMouseLeave events

  void __fastcall TForm1::Label1MouseEnter(TObject *Sender)
  {
     Label1->Caption="On";
  }

  void __fastcall TForm1::Label1MouseLeave(TObject *Sender)
  {
     Label1->Caption="Off";
  }

but label caption does not redraw. Both texts are shown simultaneously ("On" and "Off"). I tried to use

    Label1->Repaint(); 

but as it seems it does not work.

Paramore
  • 1,313
  • 2
  • 19
  • 37
  • Have you tried `Invalidate()` or `Update()` instead of `Repaint()`? Have you tried calling them on the `TCategoryPanel` instead of the `TLabel`? – Remy Lebeau Dec 29 '12 at 19:16
  • Thank you for your comment. Yes, I have tried calling both Invalidate() and Update() but without luck. What am I doing wrong? – Paramore Dec 29 '12 at 19:31
  • 2
    Set the CategoryPanel's `DoubleBuffered` property to true, then updating the Label will draw correctly without having to trigger repaints manually. – Remy Lebeau Dec 30 '12 at 02:23
  • Thank you very much Remy. It works! This is the right answer. – Paramore Dec 30 '12 at 08:43

0 Answers0