Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > BOOK: Beginning Visual C#
|
BOOK: Beginning Visual C#
This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2005, 11:32 PM
Registered User
 
Join Date: Oct 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 13 - ListView example

Hi and thanks in advance for your help.

I am working through chapter 13's example on the ListView control right now. There are 2 errors I find with it (either my fault or not .. that's what I'm trying to find out).

The first error I get occurs when opening a txt file (or any file) using the event "ItemActivate" of the ListView control. With a txt file, it seems to open the file twice. I revamped the code to use the event "DoubleClick" with the same code and it works fine.
           Why does the "ItemActivate" event open the file twice.

The second error occurs (I will assume because of the "Item Activate" event) when I open a folder. This produces a "System.ArgumentOutOfRangeException". This happens with all folders at any level. Moving back a folder works fine. The line with the error is "string filename = lw.SelectedItems[0].Tag.ToString();" and it is not in a loop.

So, that is my current situation. I have gone line by line and it is identical to the text. I am stumped. Anyone with any idea what-so-ever ... please help.

Jael

 
Old December 31st, 2005, 03:31 PM
Registered User
 
Join Date: Oct 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I may have figured out why this is happening. But I would like a guru (or at least someone who knows more than me about C#) to verify my findings.

It would appear that if I use the design editor to add an event "ItemActivate" the subscription to that event is placed in the "#region Windows Form Designer generated code" section of the code automatically. Since I had done it this way, I should have left the event subscription out of the constructor.

In any case, once I removed one or the other of the subscriptions, the code works perfectly.

Can someone validate this for me? Am I wrong in my hypothesis and conclusion?

Jael

 
Old March 8th, 2007, 03:51 AM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Jael
 I may have figured out why this is happening. But I would like a guru (or at least someone who knows more than me about C#) to verify my findings.

It would appear that if I use the design editor to add an event "ItemActivate" the subscription to that event is placed in the "#region Windows Form Designer generated code" section of the code automatically. Since I had done it this way, I should have left the event subscription out of the constructor.

In any case, once I removed one or the other of the subscriptions, the code works perfectly.

Can someone validate this for me? Am I wrong in my hypothesis and conclusion?

Jael

Hi Yor solution may correct !
But I am not using DesigerGenerated Code but I do write EventHandler Syntax manually (in vb like AddHandler ItemActivated , Addressof .... so on)
but Same thing happens with me , means ActivateEvent Executed twice ??
Why ?

Emersion





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 bwoll BOOK: Beginning Access 2003 VBA 1 June 7th, 2007 03:57 PM
Chapter 6/7 ListView Woes BigRob BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 7 March 9th, 2006 08:31 AM
Chapter 13 ElMorenito BOOK: Beginning ASP 3.0 0 January 14th, 2005 02:56 PM
Chapter 13 p. 509 arienlee BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 July 31st, 2004 07:19 AM





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