I am adding items to a c# list box and want to always scroll it to the last item added to the list so it is visible. The list will usually exceed the space available so the vertical scroll bar will display and as users can move this I need to force it jump to the end again with a new item. The only useful way I have found is to use the TopIndex property with the rows in box - number of row that can be displayed. I have this working OK with the code below unless one of the lines was too long in which case the horizontal scroll bar uses up the room for about the last 2 items. If I could figure out if the horizontal bar was displayed I could change the number of rows in the computation to account for it.
LB1.Items.Add(strText);
LB1.TopIndex = Math.Max(0,lbXmlMsg.Items.Count - 10); // 10 rows visible
This seems like a lot of work to just make sure that a new item is visible. Am I missing something ovvious here ?