Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I disable the cursor movement after hitting enter in a cell Randy R Excel Discussion (Misc queries) 1 September 16th 09 02:30 AM
Listbox header inside VBA (Array("Head1", "Head2", ...) Alex St-Pierre Excel Programming 2 October 25th 06 09:28 PM
disable form movement Liedson31 Excel Programming 2 May 9th 05 11:40 AM
how to disable listbox change event Tom Ogilvy Excel Programming 0 July 27th 04 05:55 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM


All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"