Wrox Programmer Forums
|
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 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 22nd, 2010, 05:38 PM
Registered User
 
Join Date: Nov 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 10 ex 1

Hello Rod,

I am stuck at exercise 1 of chapter 10 in your book.

The program does not copy the values of the textboxes in to the labels of the main window. I have also downloaded the exercise from your site but i can not find it. Is there something that i am forgetting?

thanks for your answer.

Joeri.
 
Old December 23rd, 2010, 01:43 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Hi Joeri,

The EditContactForm doesn't do anything itself. The main program's code initializes the form, displays it, and if the user clicks OK displays the results in the TextBoxes.

Here's part of what's in the Edit button's Click event handler:

Code:
// Create the dialog.
EditContactForm editContactInfoDialog;
editContactInfoDialog = new EditContactForm();

// Initialize the dialog.
editContactInfoDialog.firstNameTextBox.Text = firstNameLabel.Text;
editContactInfoDialog.lastNameTextBox.Text = lastNameLabel.Text;
...

// Display the dialog and check the result.
if (editContactInfoDialog.ShowDialog() == DialogResult.OK)
{
    // Save the values entered by the user.
    firstNameLabel.Text = editContactInfoDialog.firstNameTextBox.Text;
    lastNameLabel.Text = editContactInfoDialog.lastNameTextBox.Text;
    ...
}
The code inside the "if" block is what copies the values back into the main form's TextBoxes.

If that code is there and it's not copying, then probably the problem is that the EditContactForm isn't returning OK. That would happen if its OK button's DialogResult property is not set to OK.

I would check that and if it doesn't work, let me know.
I have also downloaded the exercise from your site but i can not find it.
By that do you mean that you could not find the exercise? Or that you found it but couldn't see what made it work? My guess is that its the OK button's DialogResult property. It's often hard to notice the properties set at design time because they're not spelled out in code. (In fact, to make things more obvious, some developers set all non-default property values in code so it's easy to see what you changed.)

Let me know if this solves your problem.

Best wishes,
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
 
Old December 23rd, 2010, 07:15 AM
Registered User
 
Join Date: Nov 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Rod,

It was the OK-buttons dialogproperty that was not returning the OK setting. Now it works good.

Thank u for your help.

Joeri.





Similar Threads
Thread Thread Starter Forum Replies Last Post
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 gogeo BOOK: Beginning Access 2003 VBA 1 January 22nd, 2006 09:41 AM
Chapter 10 czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 March 29th, 2005 09:35 AM
Chapter 10 columbiasmiles JSP Basics 0 May 17th, 2004 08:09 PM





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