View Single Post
  #3 (permalink)  
Old June 10th, 2013, 06:41 PM
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

I think you'll have to work through the exercise's requirements one at a time. Don't try to tackle the whole thing at once. Just focus on each task. You can either try to do them yourself or study the code to see where each requirement is met. Here are some notes about them.
Create private fields named SessionIndex1, SessionIndex2, and so forth to hold the indexes of the user’s choices.
This just means create some public variables inside the main form.
When the user clicks an ellipsis button, display the session selection dialog shown on the top in Figure 13-3.
When the user clicks the button, create a new session selection form variable as in:

Code:
SelectionForm frm = new SelectionForm();
After creating the dialog but before displaying it, set its Text property to indicate the session time as shown in the figure.
Set the dialog's Text property as in:

Code:
frm.Text = "Whatever";
Also before displaying the dialog, use code similar to the following to tell the dialog about the user’s previous selection for this session. (The SessionIndex and SessionTitle variables are public fields defined by the dialog and discussed shortly.)

Code:
frm.SessionIndex = SessionIndex1;
So this to set the form's SessionIndex property to the value in the main form's SessionIndex1 variable.

Now that you've prepared the dialog, call the dialog's ShowDialog method to display it.
If the user clicks OK, use code similar to the following to save the index of the user’s choice and to display the session’s title.
If the ShowDialog method returns OK to the main program's code, use the code to save the user's selection.
Set the ListView’s FullRowSelect property to True and set its MultiSelect property to False.

Use the Properties window to define the ListView’s column headers. Select the ListView, click its Columns property, click the ellipsis to the right, and use the editor to define the headers.

Use the Properties window’s editors to define the ListView’s items. Select the ListView, click its Items property, click the ellipsis to the right, and use the editor to define the items. Set the Text property to determine an item’s text. Click the SubItems property and then click the ellipsis to the right to define the sub-items (Room and Speaker).
Do the previous three tasks to prepare the form.
Use the following code to create public fields to communicate with the main form:
This code is in the session selection form. The main form can see it (it's public) so that's how the two forms communicate.
Create a Load event handler that uses the following code to initialize the dialog. This code selects the proper session in the ListView control and then makes the control scroll if necessary so that session is visible.
This code is in the session selection form. It gets the form ready to use.
In the OK button’s Click event handler, use the following code to save the selected item’s index and title for the main form to use:
This code is also in the session selection form. It sets the public variable values for the main form to read.

Hopefully this will help you get started or help you understand what the example code does.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

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