Scroll problem in listbox

J

John

Hi,

I'm currently working on a simple project (for study on C#) with an
input (maskedtextbox) and a listbox. The input numbers are send in the
listbox.
When the listbox is filled with numbers it automaticly puts the
scrollbar in the listbox, thats fine but it doesn't scroll down to the
last number that was keyed in and isn't visible. You have to scroll
down in the listbox itself to make the last number that was entered
visible.
What is needed to make the listbox scroll down automaticly to see the
last number inputted?

TIA,
John
 
G

Guest

Well, I am not an expert, and my solution may look rather crude to some
people, but it works. It is the same idea for what I have to use with C++
and listboxes.
Put this statement (with the name of your list box of course) at the end of
every function that prints text to a list box.


In C#:
myListBox.SelectedIndex = myListBox.Items.Count - 1;

In C++:
m_myListBox.SetCurSel(m_myListBox.GetCount() - 1);

Hey, if anyone has a better way, I would love to know as well. :-}

Hope this helps.

Rob K
 
J

John

Well Rob.
Maybe there are other (better) ways, but your (C# solution)
worked the way I wanted and is good enough.
tnx for the input.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top