Solved

TListBox & Autoscroll

Posted on 2004-04-28
17
2,512 Views
Last Modified: 2012-06-27
hi there,

i fairly new to Delphi so this might have a very simple answer,

I have a listBox and i can add items to it well enough, but when i add, lets call it, to many items a scrollbar appears on the right, good thing.

Here comes the Question:
is there a way i can make the listbox autoscroll to the last item if it is needed?

thanks in advance
Colinvanniekerk
0
Comment
Question by:colinvanniekerk
  • 4
  • 4
  • 3
  • +2
17 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10936316
add just in this way

procedure TForm1.Button1Click(Sender: TObject);
begin
  listbox1.ItemIndex := listbox1.Items.Add(edit1.Text)
end;

meikl ;-)
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10936325
var
ScrollToLast: Boolean;


If ScrollToLast then
   ListBox1.ItemIndex := ListBox1.Items.Count-1;
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 50 total points
ID: 10936369
procedure TForm1.Button1Click(Sender: TObject);
begin
  ListBox1.TopIndex := ListBox1.Items.Add('Your String');
end;
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10937427
Please colinvanniekerk, can you explain your accepting rules?

Meikl gave quiet the same answer, but before then the Ivanov G, so it was better at least a point splitting between kretzschmar and Ivanov_G

Also why a B grade? It solved exactly your question so the grade might be A...


0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10937456
its ok, f68,

ivanov's solution didn't select any item,
my solution selects allways the last item,
so it could be that ivanov's solution fits better.

but yes, colinvanniekerk, what did you expect to get for an a-grade?

meikl ;-)
0
 

Author Comment

by:colinvanniekerk
ID: 10937920
Yes it did solve my question and i do apologise again for not including the matter of selecting the last item in the list.

I assigned a grade B because i felt it was a good answer, not an excelent one.
maybe my "excelent" is not your "excelent", but the question was a simple one and therefore the highest grade i though reasonable was "Good".

I now understand that i should rather use "Excelent" for "this answer solves my problem" and "Good" for "This answer points me in the right direction" and "Average" for "this answer helped, but i still need guidance".

does that answer your question Ferruccio68?

appologies for the point distribution, i do agree that kretzschmar should get half the points as i did not mention the selection of the item. Is there any way i can change the point distribution?

colin
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10938001
btw.

>I now understand that i should rather use "Excelent" for "this answer
>solves my problem" and "Good" for "This answer points me in the
>right direction" and "Average" for "this answer helped, but i still need
>guidance".

is a good explaination :-))

meikl ;-)

0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10938033
@does that answer your question Ferruccio68?

Yes, it does :))

Now welcome to Expert Exchange, as you're a new member here in Ex-Ex....

@Is there any way i can change the point distribution?

Ask the P.E. to re-open the question for points splitting (if meikl needs it, but if i know him i think that it doesn't matter for him :)))

F68 ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10938108
>but if i know him i think that it doesn't matter for him

correct, doesn't matter for me :-))

anyway a grade-change couls also be done
(just in case, if ivanov is worry about the grade)

meikl ;-)
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10938239

  I am not worried about anything guys ... :)))
0
 

Author Comment

by:colinvanniekerk
ID: 10939040
well, thanks for the warm welcome,

I think it only fair to re-open this post so that the points can be evenly distributed amongst all three people involved, and a more acurate grading be offered.

colin

0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10939129
colinvanniekerk

thanks for your points offering, but my comment wasn't right as an assisted answer so don't worry about splitting points to me too...

and as meikl said that he don't mind about points, you could just move the grade from B to A if you want....

BTW Thanks again

F68 ;-)

0
 

Author Comment

by:colinvanniekerk
ID: 10939173
ok then, kretzschmar, could you please re-open this post so i can change the grading from B - A

thanks
colin
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10939848
If you want to select the item after the add

ListBox1.ItemIndex := ListBox1.Items.Add('SomeText');




at any other time you can call this to make the last item visible

ListBox1.Perform(LB_SETCARETINDEX, ListBox1.Items[ListBox1.Items.Count-1], MakeLParam(WORD(false), 0));
ListBox1.SetFocus;

Shane
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 100
Delphi application Soap connection 5 102
Performance of SQL statement 37 111
Delphi: barcode reading on android platform 1 26
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now