Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scrolling a ScrollBox

Posted on 1998-09-16
15
Medium Priority
?
526 Views
Last Modified: 2010-04-06
Hi!  Real easy one (I hope).  How do you get a scrollbox to scroll down as items are added to it?  Im adding dynamically labels to a ScrollBox and want the scrollbox to move down as each one is added.

Are the labels automatically destroyed when the ScrollBox is?

Thanks!!

Stu.
0
Comment
Question by:Stuart_Johnson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 5
15 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 80 total points
ID: 1339986
you will have to use the ScrollInView method of the Scrollbox

ie:

  ScrollBox1.ScrollInView( Label1 ) ;

and so long as the label has the scrollbox as its parent, then yes, it should be destroyed...

Tim
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339987
Actually you can use  ScrollBy() method,...

Regards,
Viktor Ivanov
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339988
Hi Tim,

Thanks for the quick response.  How do I get the Controls name if Im adding dynamically?

Heres a snippet:

   With TLabel.Create(Application) do begin
      Parent := sbData;
      AutoSize := True;
      WordWrap := True;
      Caption := eSItem.Text;
      Font.Color := clRed;
      Top := sbData.ControlCount*Height;
   End;

Thanks mate,


Stu.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Expert Comment

by:viktornet
ID: 1339989
TComponent(Sender).Name;

Regards,
Viktor Ivanov
0
 
LVL 35

Expert Comment

by:TimYates
ID: 1339990
Have you tried :

var
  b : tLabel ;
begin

//...

  b := tLabel.Create( Application ) ;
   With b do begin
      Parent := sbData;
      AutoSize := True;
      WordWrap := True;
      Caption := eSItem.Text;
      Font.Color := clRed;
      Top := sbData.ControlCount*Height;
   End;

  Then its name is "b" ?

  If this doesnt work, I'll try to come up with something cleverer...heh...

  Cheers,

  Tim.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 1339991
Heh, logged on at the same time as viktornet...

we seem to be competing for fastest answers...

*grin*

Tim.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339992
(Edited by Computer101), that'll do!  I didnt even think of that :)  DUH!  

Just a sec.

viktornet:

TComponent(Sender).Name = Button1

Its telling me the senders name, not the name of the new component).

0
 
LVL 35

Expert Comment

by:TimYates
ID: 1339993
*comfort*
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339994
I had a minor problem with it setting the height of the newly added labels once the scollbox started scrolling.  Heres what I came up with:

   lNewLabel := TLabel.Create(Application);
   With lNewLabel do begin
      Parent := sbData;
      AutoSize := True;
      WordWrap := True;
      Caption := eSItem.Text;
      Font.Color := clRed;
      Top := (sbData.ControlCount*Height)-sbData.VertScrollBar.Position;
   End;

'ken fantastic regardless..

Ta all.

Stu.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339995
Hello guys.....Didn't get what you mean.....

Don't mean to be sarcastic but the way Tim showed is the best way to create objects....I read it somewhere on the net...

Regards,
Viktor Ivanov
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339996
Oh, and the sbData.ScrollInView(lNewLabel) of cause :)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 1339997
Thanls Viktor :) (and good night)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339998
Good night to y'all ;-)

Regards,
Viktor Ivanov
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1339999
Thanks for your help Viktor.  Its always nice to have different things to try.

Good Night !

Stuart.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340000
Good night!

Regards,
Viktor Ivanov
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question