• STOP RIGHT MOUSE Button selecting items in a MULTISELECT listbox

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » STOP RIGHT MOUSE Button selecting items in a MULTISELECT listbox

    Author
    Topic
    #495458

    Maybe I am being dumb, but more than likely MS are..

    I have a form with a multi select listbox (simple)

    I also have a custom right mouse menu on the list box

    And yes.. it is important I have a list box NOT a subform.

    BUT.. here is the issue

    If you right mouse click over the list box, the current row is selected/deselected, before the menu pops up.

    There is a complication in that the listbox has a header row as well.

    Now, there is a dumb thing Microsoft..
    If there is NO header row, then row 0 of the list box is the first data row, and no data is a listcount of 0
    If there is a header row, then no data is a listcount of -1
    But the number of rows reported includes the header
    The data starts in row 1 NOT row 0.
    OK, I guess sometimes that might be useful.
    Shame there is very little documentation on that though.
    And it is does not appear to behave like a standard VB listbox

    IF I could be sure the user would right click over the data NOT the header, I can fudge a way round this but really
    what I want to know is

    Is there any way that I can stop the RIGHT mouse selecting or deselecting an item, BUT still have the POP UP menu.

    I have a NASTY feeling I know the answer.

    I even tried playing with mouse down event to see if I could work out where it was pressed, BUT the screen size and form location seem to possibly ruin this, and anyway it disables the menu, not the selection.

    I may just have to instruct them NOT to click over the header row !

    Anyone got any ideas??

    ===============================================================================

    HERE is one way I have got it working, but it REALLY ought to be easier, and it is a bit of a fudge.

    I used the Mouse Down Event.
    Checked the Y position which appears to be stable and relative to the top of the list box (I THINK)
    It varies with font though.

    So my code goes something like

    Code:
    IF Y <= conListBoxHeaderHeight Then
           msgbox "Please right click below the header to see the pop up menu options",vbInformation
    End If
    

    The message box seems to stop the menus as well, which is an unexpected bonus
    Which means my bodge to stop the right clicked item being changed still works.

    BUT I really want an ELEGANT solution.

    Viewing 0 reply threads
    Author
    Replies
    Viewing 0 reply threads
    Reply To: STOP RIGHT MOUSE Button selecting items in a MULTISELECT listbox

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: