Retrieving Mouse Data

  • Thread starter Thread starter Jay Banks
  • Start date Start date
J

Jay Banks

I'm working on a project that lists a few hundred items in a checked
listbox. The listbox entries are all backed up by a structure, and only
the descriptiong of the structure is shown in the listbox. Here's my
structure:

Public Structure ItemData
Dim Descriptiong As String
Dim Cost As Single
Dim Quantity As Integer
Dim Frequency As Single
Dim UnitType As MeasureUnit
End Structure

The MeasureUnit is a enumeration that details how the item is measured
(lbs, oz, grams, etc).

What I'm looking for when the user checks one of the items in the
listbox, is a way to pop up a textbox using the BringToFront method, so
they can fill in how many of these units they want.

There are two things I need to know. The first is finding out where the
mouse is, in relation to the CheckedListBox's Location, and the second
is which item was just checked.

It might help to know that I'm new to .NET, but I do have 13 years of VB
and 6 (not-all-that-great) years of C++ behind me. The concepts I can
understand... but finding the correct methods and members of the objects
is proving a little difficult for me at the moment.

Thanks for any help,
J.
 
Jay Banks said:
I'm working on a project that lists a few hundred items in a checked
listbox. The listbox entries are all backed up by a structure, and
only
the descriptiong of the structure is shown in the listbox. Here's my
structure:

Public Structure ItemData
Dim Descriptiong As String
Dim Cost As Single
Dim Quantity As Integer
Dim Frequency As Single
Dim UnitType As MeasureUnit
End Structure

The MeasureUnit is a enumeration that details how the item is
measured (lbs, oz, grams, etc).

What I'm looking for when the user checks one of the items in the
listbox, is a way to pop up a textbox using the BringToFront method,
so they can fill in how many of these units they want.

There are two things I need to know. The first is finding out where
the mouse is, in relation to the CheckedListBox's Location,

dim p as point
p = CheckedListBox1.PointToClient(cursor.position)
and the
second is which item was just checked.

In the listbox' ItemCheck event, the argument e.index returns the index of
the checked or unchecked item.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Thanks for the help Armin. It actually helped out a lot. I was in a
bit of a hurry when I wrote this, and what I needed to know was how to
tell if the list item was checked, or unchecked (after the click). I
also needed to know which item was checked, but your help showed me that.

J.
----------
 
Back
Top