![]() |
VBA - Disable up down movement inside ListBox
Hi,
I'm using office XP. I create a list box , inside ListBox I have some items, when I press up arrow and down arrow key, upper or bottom item is selected and this is done without any key-press event subroutine, it is working automatically. Is it possible somehow to disable this behavior ? I want to make my own key press event for up and down arrow keys which will select item, but only in case when some other condition meet . For example I have in ListBox 10 items, selected item is on 4th place. When I press up arrow key , event subroutine will start. This event subroutine will check one condition (from some other subroutine) , if this condition is TRUE than selection in listbox will move on 3rd place. If condition is FALSE than nothing happens, selection stays on 4th place. Zok |
VBA - Disable up down movement inside ListBox
Hi,
I added a checkbox to mimic the test condition. If the checkbox is check Up key is allowed. Private Sub ListBox1_KeyDown( _ ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = vbKeyUp Then If Not CheckBox1.Value Then KeyCode = vbNull End If ElseIf KeyCode = vbKeyDown Then ' test code hete End If End Sub Cheers Andy -Zoki- wrote: Hi, I'm using office XP. I create a list box , inside ListBox I have some items, when I press up arrow and down arrow key, upper or bottom item is selected and this is done without any key-press event subroutine, it is working automatically. Is it possible somehow to disable this behavior ? I want to make my own key press event for up and down arrow keys which will select item, but only in case when some other condition meet . For example I have in ListBox 10 items, selected item is on 4th place. When I press up arrow key , event subroutine will start. This event subroutine will check one condition (from some other subroutine) , if this condition is TRUE than selection in listbox will move on 3rd place. If condition is FALSE than nothing happens, selection stays on 4th place. Zok |
VBA - Disable up down movement inside ListBox
Will this confuse your users ?
Sometimes UP works, sometimes not. The user will have to understand why, otherwise they will think it is 'broken'. NickHK "-Zoki-" wrote in message ... Hi, I'm using office XP. I create a list box , inside ListBox I have some items, when I press up arrow and down arrow key, upper or bottom item is selected and this is done without any key-press event subroutine, it is working automatically. Is it possible somehow to disable this behavior ? I want to make my own key press event for up and down arrow keys which will select item, but only in case when some other condition meet . For example I have in ListBox 10 items, selected item is on 4th place. When I press up arrow key , event subroutine will start. This event subroutine will check one condition (from some other subroutine) , if this condition is TRUE than selection in listbox will move on 3rd place. If condition is FALSE than nothing happens, selection stays on 4th place. Zok |
VBA - Disable up down movement inside ListBox
"NickHK" wrote in message ... Will this confuse your users ? Sometimes UP works, sometimes not. The user will have to understand why, otherwise they will think it is 'broken'. Users are usually confused, but they will learn :-). And I can always put some message box with information what is happening. I need this option because I need to perform some actions in exact order so I need controlled movement in listbox. In this case that I have now in list box are listed path to images (jpg). On same user form I have image window. When I select image path in list box , this image is displayed in image window. Images are located on server and sometimes is needed cca 1s to display image after selecting in list box. So if user press too fast up and down arrow keys it is possible that some images are skipped (not displayed in image window) and this situation I want to avoid. So I want that when user press, let say key down, in list box image path is selected, in image window soon image will be displayed. But until image is not displayed I want to disable up-down key. Zok |
All times are GMT +1. The time now is 10:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com