p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Visual Basic 2010 Programmer's Reference (http://p2p.wrox.com/forumdisplay.php?f=551)
-   -   ListView on MDI child form click event (http://p2p.wrox.com/showthread.php?t=84459)

bob spencer July 22nd, 2011 07:07 PM

ListView on MDI child form click event
 
I have created a project with a series of MDI Child forms to display data in different formats. I cannot find how to detect click events on the list view.

A click event on a ListView on a normal form works fine.

A click event on the mdi child form that has the listview on it works fine.

What I want to do is get the index of the item selected in the listview.

I hope this question makes sense.

I have searched this site and MSDN, I cannot find a solution anywhere.

Thanks

Bob Spencer

Rod Stephens July 23rd, 2011 11:26 AM

I'm not completely sure I understand. I can use the ListView's SelectedIndexChanged event to tell when the user clicks on a new item. Note that the event will be called with SelectedIndices empty when it removes the old item from the selection but before it adds the new item to the selection.

I put the control in an MDI child form and it seems to work.

Do you need more than that?

(As an aside, Microsoft seems to provide less support for MDI forms with each release. I don't think their heart is really in MDI.)

bob spencer July 23rd, 2011 01:08 PM

ListView Events on a MDI Child Form
 
Rod

Thanks for getting back to me, so promptly.

It must be something to do with the way I have set my project up.

With the help of your book I have used AddHandler to detect events, and it works.

At least I can find which Item is selected.

I have bought a new machine and jumped from Windows ME to Vista, and VB3 to VB2010, I quess the learning curve was more like a cliff than a gentle gradient.

I created a sub routine to handle SelectedIndexChanged as you suggested with just a MsgBox in it, but it was never called!

Anyway I have a work round thanks to you.


Bob Spencer.

Rod Stephens July 23rd, 2011 02:36 PM

Yes, VB 3 to .NET is a pretty big jump.

If you zip up the project and email it to me, I'll take a look. I don't know why it shouldn't work.


All times are GMT -4. The time now is 12:16 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.