473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Scrolling ListBox contents?

Hello,

I have a simple application in which I am using a ListBox to display text
strings for logging purposes. When the text area becomes full the new lines
are added to the end and the vertical scroll bar becomes visible, however,
it does not automatically scroll up to show the most recent lines. What do
I need to do to get it to scroll all the way up each time a new line is
added, even though I might have previously manually pulled the scroll bar to
another position?

Thanks,
Ray Mitchell
Nov 15 '05 #1
1 6059

I came accross this problem my self. I found that listBox.TopIndex sets
the top line in the listBox. I added a global:
int nbrListBoxItems;

and in the menu initilization added:
// TODO: Add any constructor code after InitializeComponent
//
nbrListBoxItems = testListBox.ClientSize.Height /
testListBox.ItemHeight;
this determines the number of lines displayed.

Then when I added an entry I added the code:
if (testListBox.Items.Count > nbrListBoxItems)
testListBox.TopIndex = testListBox.Items.Count - nbrListBoxItems +1;

This works. I have been looking for a way to use a listBox event along
with this code so I don't have to added it after every add. I tried
using SizeChanged, but the code there never changes the listBox. I know
it must be a context thing, but I haven't figured it out yet. Anyone
have an answer?
Bill

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: J P Singh | last post by:
Hi There We have dropdown on ASP page. The problem is we have about 900 items in the dropdown. Users scrolling through the list have become very frustrated in the past. Can someone suggest...
4
by: headware | last post by:
I have a <select> control that contains many entries. It allows the user to multi-select a group of them, click a button, and store the selected data in a database. Normally they do this starting...
1
by: Wesman | last post by:
Threads, textboxes and scrolling Thanks in advance for any information on this matter. I have run into a small richtextbox, scrolling and tread issue. Which has me totally confused. Instead of...
0
by: Tim Bücker | last post by:
Hello. I have a listview and a listbox. If the listbox gets vertically scrolled, the listview should make the same movement. So I have extended the listbox control: public class...
3
by: Oddball | last post by:
Hello again, I have a problem that I can't seem to find any help for. I'm probably not typing the correct words into goo... *cough*... MSN. I have created a user control which I would like to...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
0
by: =?Utf-8?B?YW1iZXI=?= | last post by:
Hello! I have a form that contains a tabcontrol, that is populated based on which record a user selects in a listbox on the form. I just added code to 'mytab.validating' so if the user tries to...
0
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. ...
2
by: C_Kubie | last post by:
I have a populater listbox and I update the contents by running a different SQL statement via listbx.Rowsource ="<SQL statement>" The contents of the listbox changes but the form doesn't. ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.