Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Itemclick event

Status
Not open for further replies.

peekay

Programmer
Oct 11, 1999
324
ZA
I have a listview control containing certain data and every time I click an item I wish to execute the ItemClick event. Sometimes it executes this procedure twice and I cannot find out why. Is there a way to trace where an inadvertant ItemClick event is generated.<br><br>Peekay <p>PK Odendaal<br><a href=mailto: pko@mweb.co.za> pko@mweb.co.za</a><br><a href= > </a><br>
 
Set a breakpoint at the first line in the ItemClick event, and inspect the call stack from there.<br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
Nick<br>Thanks for help - if you can now just explain to me what a call stack is and how to inspect it<br> <p>PK Odendaal<br><a href=mailto: pko@mweb.co.za> pko@mweb.co.za</a><br><a href= > </a><br>
 
Show the call stack by putting in a break point and when the code stops Choose View/Call Stack from the menu.&nbsp;&nbsp;This will show what procedure called your procedure, which one called it, etc. back to the top.&nbsp;&nbsp;The top level will be a procedure that was invoked by the system.<br><br>The problem is, a click event will almost always be invoked by the system, so the call stack will always show your procedure at the top of the list, ie. no other part of your code called it.&nbsp;&nbsp;If so, the two events are either a bug in the control or some sort of timing issue.&nbsp;&nbsp;Sometimes timing issues can be resolved by adding DoEvents, such as putting it at the top of the click event, but using DoEvents can sometimes introduce more strange behavior and it slows down your code, so be cautious about using it.<br><br>If the call stack shows your click event and the same click event above it (recursion, one click event called another), then you are doing something in code that causes it to fire another click event (possible, but not likely).&nbsp;&nbsp;If so, stepping through your code from that point on may show you which line made the recursive call.<br><br>Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top