ListBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a listBox, which is filled by some database records. Once the Filling process is done, the page on the client loads.
The ploblem is , if the listbox contain to many "rows", a scrollbar will appear on the right side.

Coz this is all related to a chat, i would like to have some cliend side code to manage some way to scroll tbh scrollbar down, so i could see the last "rows" on the listbox.

Can anyone give me a help.

Thanks in advance
 
Not sure if you really want to execute this on the "client side"--i.e. with javascript, but on the server side you'd just use MyListBox.SelectedIndex = MyListBox.Items.Count - 1 (set the selected index to the last one in the last). Or, in a chat, it might be easier and more intuitive to sort the datarows in reverse chronological order--i.e. the last is first. If you are trying to do this on the client side, I know there's a javascript equivalent, something along the lines of option.selected, but I don't know the syntax. HTH

----- Me_Titus wrote: ----

I have a listBox, which is filled by some database records. Once the Filling process is done, the page on the client loads.
The ploblem is , if the listbox contain to many "rows", a scrollbar will appear on the right side.

Coz this is all related to a chat, i would like to have some cliend side code to manage some way to scroll tbh scrollbar down, so i could see the last "rows" on the listbox.


Can anyone give me a help.

Thanks in advance
 
If you want to do this client-side then use a combination of the listboxes scrollHeight and scrollTop properties.
scrollHeight is the height of the content and scrollTop stats off as 0 before you scroll down
you would want to use something like the difference in the listboxes heigt (listboxName.pixelHeight ?) and its scrollheight
so something like
listboxName.scrollTop = listboxName.scrollHeight - listboxName.pixelHeight

that sort of thing anyway!
 
Back
Top