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:
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:
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.)
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.