Mouse Move (Mouse Over)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mihail
    Contributor
    • Apr 2011
    • 759

    Mouse Move (Mouse Over)

    Hello !

    I have a form with a ListBox (can be a ComboBox as well).
    This ListBox is based on a table (or query). First column (is hidden) contain the record's IDs.

    I wish to use the MouseMove event (or other event but NOT the OnClick event) in order to obtain the ID for THAT record where the cursor is (NO click in the list).

    The same question for a regular form which display a record set (what ID has that record where the cursor is?).

    For more (but unnecessary info):
    I like to have a PictureBox (only one, in the form header or footer) where to display a .jpg file based only on the cursor position.

    Hope you understand what I mean.

    Thank you !
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    For a combobox I used:
    Code:
    Private Sub Combo0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    Me.Text2 = Me.Combo0.Column(0)
    Me.Repaint
    
    End Sub
    This works only when the form's timer is set to a value (I used 20).
    Personally I don't like using a timer on a form, as I've experienced some side-effects, but worth a try.

    The value placed in the Text2 field will be the selected value from a combobox or listbox.

    Nic;o)

    Comment

    • TheSmileyCoder
      Recognized Expert Moderator Top Contributor
      • Dec 2009
      • 2322

      #3
      You can do it with a listVIEW (ActiveX control), but I don't think you can do it with a listBOX. I don't know of any way to get the item under the cursor, without selecting it.

      Comment

      • Mihail
        Contributor
        • Apr 2011
        • 759

        #4
        Thank you (both of you) for answers.

        Yes, Smiley, this is what I am looking for.
        Thank you for the tip with ListView. I'll take a look to this control. Maybe is useful for me.

        I don't select (yet) the best answer: maybe someone have a better idea.

        Thank you, again, for yours time !

        Comment

        • TheSmileyCoder
          Recognized Expert Moderator Top Contributor
          • Dec 2009
          • 2322

          #5
          If you do not want to start using a activeX control which might not be supported in later versions of Access, then you could consider using a subform. Note however that subforms are (of course) quite different in behavior then listboxes, since they require the shift of focus from one form to another, and thus triggers record updates.

          Comment

          Working...