Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer by Rod Stephens; ISBN: 9780470596906
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 20th, 2011, 01:01 PM
Authorized User
Points: 139, Level: 2
Points: 139, Level: 2 Points: 139, Level: 2 Points: 139, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10 Tryit

I'm sure this is something simple, but I can't seem to find the solution. On the Chapter 10 Tryit, when I enter the action for the if statement to add the name to the the list box, I'm getting an error that says, "NewComedianForm.nametext is inacessible due to its protection level.
  #2 (permalink)  
Old May 21st, 2011, 10:11 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

By default in C# a control's variable is declared private so other form's can't access it directly. You can change that by setting it's Modifiers property to public.

Purists argue that you should not do this, that instead you should create a public property to get and set the control's value. In this case you would create a Name property that would get and set NameTextBox.Text.

I don't think it's that big a deal because it's pretty clear how you use a TextBox so code outside the form is less likely to mess it up. So I'd probably just set the Modifier to public and you should be good to go.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
  #3 (permalink)  
Old June 20th, 2011, 05:36 PM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default Same problem with comedianListBox

Even after I changed the modifier to "Public" for the Form1 list box "comedianListBox" . I get an error that it is not recognized. Any more suggestions?
  #4 (permalink)  
Old June 20th, 2011, 08:20 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

"Not recognized" usually means Visual Studio doesn't know that the control exists. Double check your spelling to make sure you have the right name.

Where is the code that's trying to use the control? If it's in Form1, it should be able to see all of the controls in Form1. If it's in the other form, you would need to change the Modifiers property.

If you can't figure it out, you can zip up the project and email it to RodStephens@CSharpHelper.com and I'll take a look.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
The Following User Says Thank You to Rod Stephens For This Useful Post:
Doug Snyder (June 23rd, 2011)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 10 cinek BOOK: Beginning iOS 4 Application Development 1 May 1st, 2011 10:47 AM
Chapter 10 thepianoguy BOOK: Professional iPhone and iPad Application Development 1 March 31st, 2011 11:29 AM
chapter 10 ex 1 poldeleeuw BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 2 December 23rd, 2010 07:15 AM
Chapter 10, listing 10-10-app kiwibrit BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 2 August 18th, 2009 04:21 AM
Chapter 10 JimSchubert BOOK: Ruby on Rails for Microsoft Developers 1 May 17th, 2009 11:35 PM



All times are GMT -4. The time now is 04:26 AM.


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