Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying the latest runtime text data in a control

Status
Not open for further replies.

EDHills

Programmer
Jan 24, 2007
35
US
honestly, I have dug for hours on this one already, not just a cop out.

I'm using a system.windows.forms.listbox control to display data that's being generated and I'm trying to figure out how to have it automatically display the most recent lines in the listbox without having the user do anything (i.e. control-end or pagedown until he gets to the end of the file) I guess that's a viewport into the end of the data stream. I'd love to be able to send the listbox control the equivalent of a CTRL-END whenever the text changes or something close to that.

Can anyone recommdend some keywords to search with or perhaps a different text displaying control that has support for displaying the end of the data? and yea, it is needed to be able to scroll back.

thanks for reading this far
 
Well, if what you want is to show the last entry in the listbox, just set the listbox's SelectedIndex property like so:

ListBox1.SelectedIndex = ListBox1.Items.Count - 1

This selects and scrolls to the last item in the listbox.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Have you tired setting the selected index to the last index in the collection? That might scroll it for you.

Something like:
If ListBox.Items.Count > 0 Then
ListBox.SelectedIndex = ListBox.Items.Count - 1
End If

I know that there is a way to do this in a multiline textbox that is a bit more elegant, but that method does not exist in this control.


Senior Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top