Using button to scroll down a Listbox control

Hi,
I am creating a tool which will allow users to scroll down to each item one at a time from the Listbox. However I hit upon an out of range exception each time I try as the box exceeds its index limit. So far this is the code that sort of works for me but
I am sure that there is a better way:
Private Sub btnConfirm_Click(sender As Object, e As EventArgs) Handles btnConfirm.Click
Try
ListBox1.SelectedIndex += 1
Catch ex As ArgumentOutOfRangeException
MsgBox("End of UAT!", MsgBoxStyle.Information)
End Try
End Sub
I rather not generate an exception if I can contain this within a specified range but have been struggling to do so. So really what I am looking for would be something like this:
Get maximum number of items in the List box 
Dim numberOfItems As Integer = ListBox1.Items.Count
Create a range with numberOfItems being the upper limit 
Then let ListBox1.SelectedItem +=1 operate within this range and not go above.
I am not sure how I would implement this so any suggestions or pointers will be much appreciated.
Kind Regards,
MobileIAm 

You need to test what the SelectedIndex is before you add or subtract 1 from the SelectedIndex.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'move up through the items
If ListBox1.Items.Count > 0 Then
If ListBox1.SelectedIndex <= 0 Then
ListBox1.SelectedIndex = ListBox1.Items.Count - 1
Else
ListBox1.SelectedIndex -= 1
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'move down through the items
If ListBox1.Items.Count > 0 Then
If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then
ListBox1.SelectedIndex = 0
Else
ListBox1.SelectedIndex += 1
End If
End If
End Sub
If you say it can`t be done then i`ll try it

Similar Messages

  • Unable to scroll down in table control screen .

    Hi techies ,
    am attaching the table control screen .
    am not able to scroll down in that .
    and also may i know the reason why am not able to tick the checkbox ?
    it seems in disable mode .

    Hi Ajay,
    It was the only reason, ever i have faced...
    And other possibility is regarding tbc-lines, but i saw that you were doing this using describe table.
    Sometimes the table control will not show all the records in internal table(case while changing number of records in internal table each time )..
    At this case you have to set the lines in TBC.. using
    describe table itab lines tbc-lines.
    tbc-lines is very useful, if you want to enable a new blank line in table control, just do this
    tbc-lines = tbc-lines + 1.
    Explore all properties of table control it is very useful.
    I think, i could solved your issue.. thanks for your appreciation.
    Regards
    Sreekanth

  • When I try to access a picture from i photo the picture will come up and then quickly the screen goes black and there is a white exclamation mark.  Also when using faces and scrolling down pictures some disappear very quickly after a brief look.

    When using i photo and trying to pull up individual photos - the photo will appear and quickly disappear only to be replaced by a black screen with a white explanation mark.  This happens with all of my photos.  Has anyone had this problem and if so what can be done to fix it.  I did not select this graphic to be added to my i photo pictures - the blace sign with the white explanation mark.  Also, when scrolling down photos in faces some of my pictures disappear after a quick view. 
    Thanks for any help you can provide.  It seems like something has gotten into my i photo picture account?

    The ! turns up when iPhoto loses the connection between the thumbnail in the iPhoto Window and the file it represents.
    What version of iPhoto? Assuming 09 or later...
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • How to create a button which scrolls down with the page automatically?

    Hello,
    I wanted to create a button which takes u back to the top of the page when pressed on, but I was wondering how to make it scroll down with the page on the right side automatically when some1 scrolls down the page.
    An example I saw was on tumblr.com
    P.S I'm a newbie, so please explain it clearly ;d.
    Thanks.

    Create a button, position it as fixed at the top right say,
    a button{
              position:fixed;
              top:50px;
              right:50px; 
    <a href="#home"><button> Button</button></a>
    The <a> is the link to take you to the top of the page
    Just be sure to set the id home on an element at the top of the page

  • My space button keeps scrolling down, my internet pages (FB) keeps shutting down??help

    Help! everytime i press space my page scrollsdown , everytime i press delete the option to leave the page im on appears. mY I PHOTO is damaged(i cannot open it ) some pages on the internet sduch as openuniversity when i get onto the page is just closes the internet and asks me if i wantt o re open it, so frustrating!!please help

    http://www.amazon.com/Genuine-BlackBerry-J-M1-Battery-Torch/dp/B005IROX3U
    http://shop.crackberry.com/blackberry-jm-1-1230mah-standard-battery/8A37A8699.htm
    Here are some links for ordering online. And your very welcome for your help.
    1. If a post has helped you, show your appreciation by clicking Like at the bottom of the message box.
    2. If a post has solved your question, please click ''accept as solution'' to verify your question has been solved.

  • Mavericks Mail-cannot scroll down to select a group by holding mouse button.

    I do not like the new Mavericks mail. When I attempt to hold the left mouse button and scroll down to select a group, the program automatically locks onto the first message I touch and moves it. Prior to Mavericks scrolling was an easy process. This new mail is very clumsy and I have to select one message, then hold shift key, then selelct the last message in the group. ....Clumsy and slow.
    Does anyone know a workaround for this? The tutorials don't address it and the "What's new in Mail?" file doesn't either.  If there is not a workaround, is there a way to disable the Mavericks configuration in Mail and go back to regular mail? I'd appreciate any tips or help on  this.

    Okay, I tried deleting the Finder preferences first (along with a handful of other preference files that I knew were no longer needed), and it seemed to help--at first. But eventually, all the same problems started happening again, so I concluded that it was necessary to just start with a fresh (empty) preferences folder. As you know, this is a pain to deal with, but I limited my pain by moving all the old preferences files into a folder on the Desktop rather than simply deleting them. That way, I could just put back any missing preferences that were too hard to recreate. Restoring all of my preferences with new (uncorrupted) prefs files will be an ongoing process, but the good news is that this effort (so far) seems to have solved the problem. Mail is responding to all my clicks, even when I switch between different apps and different spaces.  :-)
    Now that things are working correctly, I notice that when I switch between apps and/or spaces, the selected app (or the frontmost app in the new space) will show an active state for its window, whereas before, the selected app didn't update to show that it was active--it kept the inactive state for its window. I'm no expert, but it seems to me that this might have something to do with the windowserver process, so it might make sense for the next person who stumbles on this thread to start by deleting any preferences files that begin with com.apple.windowserver. Just a hunch, but it's worth starting there before you do a complete flush of all your preferences.
    Thanks again for the help--hopefully this workaround will be persistent. Fingers crossed!

  • Apple mouse will not scroll down

    I have a wirelss mouse (not a Magic Mouse).  The poor creature will not scroll down, infact when using the track button to scroll down, it will go up.  Any suggestions as to how this can be cured.  When I had Apple Care (it is now expired) of the experts suggested rubbing a piece of paper vigoursly over the button a few dozen times - however the mouse now seems to have developed a resistence to this treatment. 

    You're in the Time Capsule forum...no one here focusing on mice.  However...maybe this can help:
    https://discussions.apple.com/thread/3193635?start=0&tstart=0

  • All web pages appear with a blinking cursor like in a "word document". i can't scroll down or up using the buttons of my key board. i have to pull down the scroll bar. something in settings has changed. how to correct it??

    all web pages appear with a blinking cursor like in a "word document". i can't scroll down or up using the buttons of my key board. i have to pull down the scroll bar. something in settings has changed. how to correct it??
    == This happened ==
    Just once or twice
    == 2 days ago.

    See also this article about caret browsing: http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    In Firefox 3.6 and later versions you can disable the F7 shortcut that toggles caret browsing by setting the pref accessibility.browsewithcaret_shortcut.enabled to false.
    To open the ''about:config'' page, type '''about:config''' in the location (address) bar and press the Enter key, just like you type the url of a website to open a website.
    If you see a warning then you can confirm that you want to access that page.

  • Table Scroll down using a button

    Hi,
    Can some expert Webdynpro consultant try out this weird requirement and give me the solution. ( Its for an app to be used on Mobile which is why asking for it. Its working fine on computers/Laptops)
    Create a table and bind it with a child node and fill it with data so that it has many rows.. Now for scrolloing down, instead of using the scroll down button provided by the table element, create a new button which will perform the same functionality of scrolling down.
    I have found the class which has the method which perform this functionality but am not able to use it properly.
    The class is CL_WDR_P13N_DT and the method is AGGR_MOVE_DOWN.
    I have tried MOVE_ELEMENT and all move related methods of if_wd_context_node, these methods just change the index position, they dont move the table contents down. So pls dont waste your time on that.
    I have used this code:
    DATA: lo_nd_resb_tab TYPE REF TO if_wd_context_node,
              vn type ref to CL_WDR_P13N_DT.
    lo_nd_resb_tab = wd_context->get_child_node( name = 'EKKO_TAB' ).
    create object vn.
    CALL METHOD VN>AGGR_MOVE_DOWN
    EXPORTING
    VISIBLE_NODE = lo_nd_resb_tab
    Thanks & Regards

    Hi Fawaz,
    To scroll to the required column or row in the output, use the methods of the interface
    class IF_SALV_WD_TABLE_SETTINGS (implementing class
    CL_SALV_WD_CONFIG_CLASS).
    Methods for Horizontal and Vertical Scrolling
    Function                                                                                 Method
    Specify row to be displayed as the first row -             SET_FIRST_VISIBLE_ROW
    Get row to be displayed as the first row -                  GET_FIRST_VISIBLE_ROW
    Specify column to be displayed as the first column -  SET_FIRST_VISIBLE_SCROLL_COL
    Get column to be displayed as the first column -       GET_FIRST_VISIBLE_SCROLL_COL
    regards,
    Amol

  • Since installing the latest version I cannot scroll down my pages using the button on the pad on my laptop

    I had the old version of Firefox and was invited to install this version when it had finished i went back on line only to find the button on the laptop mouse pad no longer scrolls down the page. I now have to drag it down with the bar at the side.

    Use "Firefox > Exit" (Windows: Firefox/File > Exit; Mac: Firefox > Quit Firefox; Linux: Firefox/File > Quit) to close Firefox if you are currently doing that by clicking the close X on the Firefox title bar.
    See also:
    *"Hang at exit": http://kb.mozillazine.org/Firefox_hangs
    *"Firefox hangs when you quit it": https://support.mozilla.org/kb/Firefox+hangs
    You can check if there is still a Firefox process visible in the Windows Task Manager.
    *http://kb.mozillazine.org/Kill_application

  • The insert cursor is at the top of the page and as i scroll down the insertion cursor scrolls down as well when I use the directional buttons.

    in all tabs once i open firefox the scrolling is kind of messed up. IE i'll be on any web site and click the down button it scrolls all the way down to the bottom or it will only scroll some. It was a problem months ago and have recently reinstalled Firefox and the problem persists. Please help

    Maybe you have Caret browsing turned on? It is toggled with the '''F7''' key.
    http://kb.mozillazine.org/Accessibility.browsewithcaret

  • I updated to the latest version and now I do not have the page controls at the right hand side and bottom and can only move the page up and down using the mouse scroll wheel. I also cannot see the whole page I am trying to view.

    When I open the web browser I cannot see the whole page and I cannot move the image sideways and must use the mouse scroll to move up and down.

    Try the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home/Library/ Preferences folder.
    2 - delete the contents the following folder:
    User/Library/Containers/com.apple.iPhoto
    3 - reboot, launch iPhoto and try again.
    NOTE: For Mavericks, 10.9,  go to your Home folder and use the View ➙ Show View Options menu to bring the this window:
    where you can check the Show Library Folder checkbox.

  • LSMW -t-code Po13-Recording Table control-SCroll down

    Hi,
    How do we process Scrolling in LSMW?
    I am trying to record T-code Po13 where I have a table control in which I need to SCroll down and select a infoset and hit Create button.The Infoset which i am selecting is not present on direct screen thats why i need to scroll down.
    Any ideas?
    Or shall i choose dierent methods for this requirement?
    Regards
    Praveen

    Hi,
    I'd suggest to use BAPI or DI program if it's available, instead of recording.
    BAPI BAPI_HRMASTER_SAVE_REPL_MULT might help you.
    Best regards,
    Peter

  • Firefox scroll-down button out of view

    Good evening,
    I've been so used to using my trackpad to scroll down when i'm on the internet that today when I looked at the bottom right corner of my browser, I was surprised to find that my scroll-down button was missing. I don't think it's really missing, it seems to be that the resize button below the scroll buttons seems to be covering the scroll-down button, that I can't click it.
    Can I somehow move the scroll buttons up or something? I can't seem to get the resize button out of the way.
    MacBook Pro Mac OS X (10.4.9)

    Check your permissions using disk utility but i think re-installing firefox will be the best fix, that or locate and trash the firefox preference files.
    Cheers.

  • Can i make a button change anchor link when you scroll down the site?

    I am trying to make a scroll site.. and i have navigation buttons on the right, a full menu, but also a "1 topic up" button and "1 topic down" button.
    Is there any way that i can have those buttons change anchor link when you scroll down the site.
    Example:
    I am at home, then i press "1 topic down" and gets scrolled to the next topic on the website, but then i cant make the button change to link to the anchor below that, so the button becomes useless after that 1 press.
    Is that in any way possible in Muse to make it change link?

    Hi
    You can try to create different buttons on page positions where down scrolling will be active with separate button actions. For example you click on "I topic down" , page scrolls and there is another button placed with "Next Topic down" , on click this would scroll the page more and similarly along the length of page.
    Button with anchor link scrolling down the page cannot be used for different anchor links, creating different buttons with anchors is the solution.
    Thanks,
    Sanjit

Maybe you are looking for

  • View object that will allow to see data from two tables in a adf table

    Hi, I've been have serious issues to resolve this functional requirements with ADF. Basically I have two tables let say employee and department. A need a read only adf table to show the employees values but I don't want the users to see the departmen

  • Attempting to set up "output module" in bridge CC - no workspace folder in Bridge CC. sol1 ok sol2 !

    Using AOM_Package_Win64.zip I was able to copy  "adobe output module" folder to Bridge CC extention. I could not follow your step3, namely "Copy the AdobeOutputModule.workspace file into the Workspaces folder under the Bridge CC Extensions folder." I

  • Very large time series database

    Hi, I am planning to use BDB-JE to store time series data. I plan to store 1 month worth of data in a single record. My key consists of the following parts: id,year_and_month,day_in_month My data is an array of 31 doubles (One slot per day) For examp

  • OSB11g Workbench JCA Transport page error

    Hello In latest OSB11g (WLS 10.3) workbench comes an error in JCA Transport page as "The JCA Transport page of this editor contains an error which must be resolved." if JCA address is given in protocol page. Then the page JCA Transport Configuration

  • Computer turns off

    My computer shuts off when Im on the internet.