ID item under a mouse move over a long list RRS feed

  • Question

  • i'm using the mouseMove's eventargs's Y value to see where the mouse is over the control and can detect which item is under the mouse by dividing that value by the list's getItemHeight(0) (all items are text and the same height) but when the list is too long to fit on the screen without a scroll, scrolling down ruins this calculation.  How can I measure how many items are above the control's visible list for this to work?

    int intItemHeight 
              = lst.Items.Count > 0 
                                ? lst.GetItemHeight(0)
                                : lst.Font.Height;
    int intIndex = e.Y / intItemHeight + (intNumberItemsNotVisibleAboveScrollLine);

    how do I determine the value of intNumberItemsNotVisibleAboveScrollLine?


    my code is perfect until i don't find a bug

    Sunday, February 3, 2019 10:15 AM


All replies