View Single Post
 
Old November 13th, 2012, 11:41 AM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
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

Hi MinusZero,

I'm sorry you're finding this TryIt frustrating. If you get stuck on something, like creating the first form, email me or post here and I'll try to get you going again as quickly as possible. (For example, when you needed to change the startup form.)

Sorry the instructions don't say to build the main form first. That is confusing. I think I was considering the dialog to be the more interesting part of this problem so I started with it first. (When I program, I sometimes do that. I would create the project, ignore the startup form for now, and create the dialog first.)

This is left over from previous examples.

Code:
ListViewItem lvi = itemsListView.Items.Add(frm.ItemName);
lvi.SubItems.Add(frm.PriceEach.ToString("C"));
lvi.SubItems.Add(frm.Quantity.ToString("C"));
lvi.SubItems.Add(frm.TotalPrice.ToString("C"));
The values in red are declared in the dialog. (This is the main reason I built the dialog first. This code can't work in the main form until the dialog is built.) On the top of page 170 it says to create those fields in the dialog form's code outside of any methods.

Because they are public and outside of the methods, the main form's code can access them if it has a variable that refers to a dialog form. In this case, frm refers to one of those forms so frm.PriceEach refers to the PriceEach field owned by that form.

Quote:
This code from the downloaded Lesson 13 Try it contains NumberStyles.Any. When i try to type it, Intellisense doesnt find such an item.
Sorry about that. It's used on page 136 but as System.Globalization.NumberStyles.Any. This example uses a "using System.Globalization" statement at the top so later it can use NumberStyles.Any without starting it with "System.Globalization."

Quote:
I have no idea what is happening and am at my wits end. The book seems to be becoming less helpful as more and more it seems to assume a novice coder has the knowledge to complete something that isnt shown. I might move to the next chapter and live without chapter 13. I dont think it will be a problem.
Again I'm sorry about that. The book does assume you know more as you progress but there do seem to be some things here that are a bit of a stretch.

Please email or post if you get stuck. The book should be challenging but it's not intended to be an exercise in pain and frustration.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)