Recent

Author Topic: [SOLVED] TScrollBox Not Scrolling to Focused TDBEdit in Lazarus  (Read 266 times)

lhl

  • New member
  • *
  • Posts: 9
I have the following situation in Lazarus:

A TScrollBox on a form.
Inside this TScrollBox, there are two TDBEdit components.
The first TDBEdit is visible within the display area.
The second TDBEdit is also inside the TScrollBox, but it's out of view and requires scrolling to be seen.
Problem:
When navigating between fields using the Tab key, the TScrollBox does not scroll automatically to reveal the TDBEdit that receives focus. The field is correctly focused, but visually it remains hidden.

Question:
How can I make the TScrollBox automatically scroll to show the component that has received focus?
« Last Edit: March 17, 2025, 11:33:37 am by lhl »

korba812

  • Sr. Member
  • ****
  • Posts: 464
Re: TScrollBox Not Scrolling to Focused TDBEdit in Lazarus
« Reply #1 on: March 14, 2025, 06:14:42 pm »
You can use TScrollBox.ScrollInView method in conjunction with OnEnter event of your edit controls.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.DBEdit1Enter(Sender: TObject);
  2. begin
  3.   ScrollBox1.ScrollInView(TControl(Sender));
  4. end;
  5.  

lhl

  • New member
  • *
  • Posts: 9
Re: TScrollBox Not Scrolling to Focused TDBEdit in Lazarus
« Reply #2 on: March 16, 2025, 04:06:25 pm »
Thanks, resolved!

 

TinyPortal © 2005-2018